From a8977729fea74410de53df3939ab1cce9d73f88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 21 Mar 2023 16:39:31 +0100 Subject: [PATCH] Fixed: [similar person matcher] properly takes person center into account Center comes from the table person_center_history, not person.center_id --- .../ChillPersonBundle/Search/SimilarPersonMatcher.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index 6555f7835..b7e2c12b0 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -76,8 +76,17 @@ class SimilarPersonMatcher $qb->select('p') ->from(Person::class, 'p') + ->join('p.centerHistory', 'center_history') ->where('SIMILARITY(p.fullnameCanonical, UNACCENT(LOWER(:fullName))) >= :precision') - ->andWhere($qb->expr()->in('p.center', ':centers')); + ->andWhere($qb->expr()->in('center_history.center', ':centers')) + ->andWhere($qb->expr()->andX( + $qb->expr()->lte('center_history.startDate', 'CURRENT_DATE()'), + $qb->expr()->orX( + $qb->expr()->isNull('center_history.endDate'), + $qb->expr()->gt('center_history.endDate', 'CURRENT_DATE()') + ) + )) + ; $qb ->setParameter('fullName', $this->personRender->renderString($person, []))