mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-08 06:19:42 +00:00
Search person by phonenumber: allow searching though identifier and phonenumber
This commit is contained in:
@@ -161,21 +161,33 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
|
|||||||
$andWhereSearchClause[] = '('.implode(' OR ', $q).')';
|
$andWhereSearchClause[] = '('.implode(' OR ', $q).')';
|
||||||
$andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, ...$qArguments];
|
$andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, ...$qArguments];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (null !== $phonenumber) {
|
|
||||||
$andWhereSearchClause[] =
|
|
||||||
"person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR (EXISTS (SELECT 1 FROM chill_person_phone WHERE person.id = person_id AND phonenumber LIKE '%' || ? || '%'))";
|
|
||||||
array_push($andWhereSearchClauseArgs, $phonenumber, $phonenumber, $phonenumber);
|
|
||||||
} */
|
|
||||||
|
|
||||||
$query->andWhereClause(
|
|
||||||
\implode(' AND ', $andWhereSearchClause),
|
|
||||||
$andWhereSearchClauseArgs
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$pertinence = ['1'];
|
$pertinence = ['1'];
|
||||||
$pertinenceArgs = [];
|
$pertinenceArgs = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $phonenumber) {
|
||||||
|
$personPhoneClause = "person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR EXISTS (SELECT 1 FROM chill_person_phone where person_id = person.id AND phonenumber LIKE '%' || ? || '%')";
|
||||||
|
if (count($andWhereSearchClauseArgs) > 0) {
|
||||||
|
$initialSearchClause = '(('.\implode(' AND ', $andWhereSearchClause).') OR '.$personPhoneClause.')';
|
||||||
|
}
|
||||||
|
$andWhereSearchClauseArgs = [...$andWhereSearchClauseArgs, $phonenumber, $phonenumber, $phonenumber];
|
||||||
|
|
||||||
|
// drastically increase pertinence
|
||||||
|
$pertinence[] = "(person.phonenumber LIKE '%' || ? || '%' OR person.mobilenumber LIKE '%' || ? || '%' OR EXISTS (SELECT 1 FROM chill_person_phone where person_id = person.id AND phonenumber LIKE '%' || ? || '%'))::int * 1000000";
|
||||||
|
$pertinenceArgs = [...$pertinenceArgs, $phonenumber, $phonenumber, $phonenumber];
|
||||||
|
} else {
|
||||||
|
$initialSearchClause = \implode(' AND ', $andWhereSearchClause);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($initialSearchClause)) {
|
||||||
|
$query->andWhereClause(
|
||||||
|
$initialSearchClause,
|
||||||
|
$andWhereSearchClauseArgs
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$query
|
$query
|
||||||
->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs);
|
->setSelectPertinence(\implode(' + ', $pertinence), $pertinenceArgs);
|
||||||
|
|
||||||
@@ -214,7 +226,6 @@ final readonly class PersonACLAwareRepository implements PersonACLAwareRepositor
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (null !== $city) {
|
if (null !== $city) {
|
||||||
$query->setFromClause($query->getFromClause().' '.
|
$query->setFromClause($query->getFromClause().' '.
|
||||||
'JOIN view_chill_person_current_address vcpca ON vcpca.person_id = person.id '.
|
'JOIN view_chill_person_current_address vcpca ON vcpca.person_id = person.id '.
|
||||||
|
Reference in New Issue
Block a user