From bc99c85802bd4c5294894deb012376e91811b81a Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 15 Feb 2022 13:16:04 +0100 Subject: [PATCH 1/4] thirdparty search: add where clause for searching into children --- .../ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 994b9d65c..4144db6a0 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -87,8 +87,12 @@ class ThirdPartyApiSearch implements SearchApiInterface foreach ($strs as $str) { if (!empty($str)) { $wheres[] = "(LOWER(UNACCENT(?)) <<% tparty.canonicalized OR - tparty.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%')"; - $whereArgs[] = [$str, $str]; + tparty.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%') + OR + (LOWER(UNACCENT(?)) <<% parent.canonicalized OR + parent.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%') + "; + $whereArgs[] = [$str, $str, $str, $str]; $pertinence[] = 'STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized) + ' . "(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int + " . // take postcode label into account, but lower than the canonicalized field From f5bc8dca5e82b6dbaba088587e7499a416fc8577 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 15 Feb 2022 13:39:46 +0100 Subject: [PATCH 2/4] thirdparty search: adapt pertinence select clause for searching into children --- .../Search/ThirdPartyApiSearch.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index 4144db6a0..a50d35cf2 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -93,12 +93,18 @@ class ThirdPartyApiSearch implements SearchApiInterface parent.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%') "; $whereArgs[] = [$str, $str, $str, $str]; - $pertinence[] = 'STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized) + ' . - "(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int + " . + $pertinence[] = "GREATEST( + STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized), + STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), parent.canonicalized) + ) + " . + "GREATEST( + (tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int, + (parent.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int + ) + " . // take postcode label into account, but lower than the canonicalized field "COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0) + " . "COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0)"; - $pertinenceArgs[] = [$str, $str, $str, $str]; + $pertinenceArgs[] = [$str, $str, $str, $str, $str, $str]; } } From 489473806f5d1a8658a22cb22b252aa19c248975 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 15 Feb 2022 13:41:59 +0100 Subject: [PATCH 3/4] upd CHANGELOG --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c392663a..ec16d8ede 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to ## Unreleased - +* [thirdparty] Extend the thirdparty search to thirdparty children (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/448) ## Test releases ### test release 2022-02-14 @@ -22,7 +22,7 @@ and this project adheres to * [person] accompanying course work: fix on-the-fly update of thirdParty * fix normalisation of accompanying course requestor api (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/378) * [person] add a returnPath when clicking on some Person or ThirdParty badge (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/427) -* [person] accompanying course work: fix on-the-fly update of thirdParty +* [person] accompanying course work: fix on-the-fly update of thirdParty * [on-the-fly] close modal only after validation * [person] correct thirdparty PATCH url + add email and altnames in AddPerson and serializer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/433) * change order for accompanying course work list From 96b1854fef386fe6d0f2c80d205a234ff0b28fff Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 15 Feb 2022 13:57:02 +0100 Subject: [PATCH 4/4] php code style fix --- .../ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php index a50d35cf2..e4b7f43af 100644 --- a/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php +++ b/src/Bundle/ChillThirdPartyBundle/Search/ThirdPartyApiSearch.php @@ -93,10 +93,10 @@ class ThirdPartyApiSearch implements SearchApiInterface parent.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%') "; $whereArgs[] = [$str, $str, $str, $str]; - $pertinence[] = "GREATEST( + $pertinence[] = 'GREATEST( STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized), STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), parent.canonicalized) - ) + " . + ) + ' . "GREATEST( (tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int, (parent.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int