From 06b7e8427003c6875c08b45a4e20c64a751fb571 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Mar 2023 13:48:01 +0100 Subject: [PATCH 1/6] FIX [thirdparty][profession] set default value for profession in symfony form --- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 384c743c2..b1446a543 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -110,6 +110,7 @@ class ThirdPartyType extends AbstractType ->add('profession', TextType::class, [ 'label' => 'thirdparty.Profession', 'required' => false, + 'empty_data' => '', ]) ->add('contactDataAnonymous', CheckboxType::class, [ 'required' => false, From c729a1430473b7d3d9e889a5e0bd35c5f7596e82 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Mon, 20 Mar 2023 07:54:16 +0100 Subject: [PATCH 2/6] FIX [minor] remove dump, use statement, ... --- src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php index 6555f7835..c2caf13bb 100644 --- a/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php +++ b/src/Bundle/ChillPersonBundle/Search/SimilarPersonMatcher.php @@ -117,7 +117,6 @@ class SimilarPersonMatcher $qb->setParameter('fullName', $this->personRender->renderString($person, [])); } - dump($qb->getQuery()); return $qb->getQuery()->getResult(); } } From df2480c47c3bbe72be73396736b01445b9689383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 20 Mar 2023 21:36:46 +0100 Subject: [PATCH 3/6] Fixed: transform null value into emtpy string into ThirdParty::setProfession --- src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index b13118168..29565e86a 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -807,10 +807,10 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface /** * @return $this - */ - public function setProfession(string $profession): self + */"" + public function setProfession(?string $profession): self { - $this->profession = $profession; + $this->profession = (string) $profession; return $this; } From ecac40958696e0ad588b8b3a434e95a0c0961397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 20 Mar 2023 21:38:42 +0100 Subject: [PATCH 4/6] fixed: fix 3party syntax --- src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 29565e86a..966e40bd1 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -805,9 +805,6 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface return $this; } - /** - * @return $this - */"" public function setProfession(?string $profession): self { $this->profession = (string) $profession; 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 5/6] 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, [])) From 4eb7d10e459b4dd5b99d288f08132a63c5a716e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Mar 2023 11:23:14 +0100 Subject: [PATCH 6/6] Fixed: [calendar ms synchro] do not throw an error if we are not allowed to get the default calendar --- .../Connector/MSGraph/MapCalendarToUser.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php index 504d48ffc..563bd3a38 100644 --- a/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php +++ b/src/Bundle/ChillCalendarBundle/RemoteCalendar/Connector/MSGraph/MapCalendarToUser.php @@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\User; use DateTimeImmutable; use LogicException; use Psr\Log\LoggerInterface; +use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface; use Symfony\Contracts\HttpClient\HttpClientInterface; use function array_key_exists; @@ -74,9 +75,18 @@ class MapCalendarToUser public function getDefaultUserCalendar(string $idOrUserPrincipalName): ?array { - $value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [ - 'query' => ['$filter' => 'isDefaultCalendar eq true'], - ])->toArray()['value']; + try { + $value = $this->machineHttpClient->request('GET', "users/{$idOrUserPrincipalName}/calendars", [ + 'query' => ['$filter' => 'isDefaultCalendar eq true'], + ])->toArray()['value']; + } catch (ClientExceptionInterface $e) { + $this->logger->error('[MapCalendarToUser] Error while listing calendars for a user', [ + 'http_status_code' => $e->getResponse()->getStatusCode(), + 'id_user' => $idOrUserPrincipalName, + ]); + + return null; + } return $value[0] ?? null; }