From 8de37a9ef3298dfeef10c9daa4c436c797889944 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 11 Apr 2024 16:45:22 +0200 Subject: [PATCH 1/6] Fix import of postal codes. URL changed + names of keys --- .../Service/Import/PostalCodeFRFromOpenData.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index e5934af3b..c073e5bdb 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -23,7 +23,7 @@ use Symfony\Contracts\HttpClient\HttpClientInterface; */ class PostalCodeFRFromOpenData { - private const CSV = 'https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/data-files/019HexaSmal.csv'; + private const CSV = 'https://datanova.laposte.fr/data-fair/api/v1/datasets/laposte-hexasmal/metadata-attachments/base-officielle-codes-postaux.csv'; public function __construct(private readonly PostalCodeBaseImporter $baseImporter, private readonly HttpClientInterface $client, private readonly LoggerInterface $logger) { @@ -50,7 +50,7 @@ class PostalCodeFRFromOpenData fseek($tmpfile, 0); $csv = Reader::createFromStream($tmpfile); - $csv->setDelimiter(';'); + $csv->setDelimiter(','); $csv->setHeaderOffset(0); foreach ($csv as $offset => $record) { @@ -65,23 +65,23 @@ class PostalCodeFRFromOpenData private function handleRecord(array $record): void { - if ('' !== trim($record['coordonnees_geographiques'] ?? $record['coordonnees_gps'])) { - [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', $record['coordonnees_geographiques'] ?? $record['coordonnees_gps'])); + if ('' !== trim($record['_geopoint'])) { + [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', $record['_geopoint'])); } else { $lat = $lon = 0.0; } - $ref = trim((string) $record['Code_commune_INSEE']); + $ref = trim((string) $record['code_commune_insee']); if (str_starts_with($ref, '987')) { // some differences in French Polynesia - $ref .= '.'.trim((string) $record['Libellé_d_acheminement']); + $ref .= '.'.trim((string) $record['libelle_d_acheminement']); } $this->baseImporter->importCode( 'FR', - trim((string) $record['Libellé_d_acheminement']), - trim((string) $record['Code_postal']), + trim((string) $record['libelle_d_acheminement']), + trim((string) $record['code_postal']), $ref, 'INSEE', $lat, From e8b95f8491252e64050e9630998930eef3b2b419 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 11 Apr 2024 16:45:43 +0200 Subject: [PATCH 2/6] Add changie for fix import postal codes --- .changes/unreleased/Fixed-20240411-164104.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/unreleased/Fixed-20240411-164104.yaml diff --git a/.changes/unreleased/Fixed-20240411-164104.yaml b/.changes/unreleased/Fixed-20240411-164104.yaml new file mode 100644 index 000000000..aa63f022a --- /dev/null +++ b/.changes/unreleased/Fixed-20240411-164104.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: 'Postal codes import : fix the source URL and the keys to handle each record' +time: 2024-04-11T16:41:04.786062252+02:00 +custom: + Issue: "250" From dbb9feb12980f474698dd42a05f6a88bd73c1993 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 12 Apr 2024 12:35:52 +0200 Subject: [PATCH 3/6] rector correction: cast value to string --- .../Service/Import/PostalCodeFRFromOpenData.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php index c073e5bdb..e40b4dff9 100644 --- a/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php +++ b/src/Bundle/ChillMainBundle/Service/Import/PostalCodeFRFromOpenData.php @@ -65,8 +65,8 @@ class PostalCodeFRFromOpenData private function handleRecord(array $record): void { - if ('' !== trim($record['_geopoint'])) { - [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', $record['_geopoint'])); + if ('' !== trim((string) $record['_geopoint'])) { + [$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', (string) $record['_geopoint'])); } else { $lat = $lon = 0.0; } From 4091efc72ec308931fcb3d0d740c0895b9c6ff6e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 12 Apr 2024 12:58:23 +0200 Subject: [PATCH 4/6] Update bundles version to 2.18.2 --- .changes/unreleased/Fixed-20240411-164104.yaml | 5 ----- .changes/v2.18.2.md | 3 +++ CHANGELOG.md | 4 ++++ 3 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 .changes/unreleased/Fixed-20240411-164104.yaml create mode 100644 .changes/v2.18.2.md diff --git a/.changes/unreleased/Fixed-20240411-164104.yaml b/.changes/unreleased/Fixed-20240411-164104.yaml deleted file mode 100644 index aa63f022a..000000000 --- a/.changes/unreleased/Fixed-20240411-164104.yaml +++ /dev/null @@ -1,5 +0,0 @@ -kind: Fixed -body: 'Postal codes import : fix the source URL and the keys to handle each record' -time: 2024-04-11T16:41:04.786062252+02:00 -custom: - Issue: "250" diff --git a/.changes/v2.18.2.md b/.changes/v2.18.2.md new file mode 100644 index 000000000..42eff9e25 --- /dev/null +++ b/.changes/v2.18.2.md @@ -0,0 +1,3 @@ +## v2.18.2 - 2024-04-12 +### Fixed +* ([#250](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/250)) Postal codes import : fix the source URL and the keys to handle each record diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c0a6b008..ae9407c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and is generated by [Changie](https://github.com/miniscruff/changie). +## v2.18.2 - 2024-04-12 +### Fixed +* ([#250](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/250)) Postal codes import : fix the source URL and the keys to handle each record + ## v2.18.1 - 2024-03-26 ### Fixed * Fix layout issue in document generation for admin (minor) From 8516e89c9cac8b8be16a581ef9a55bafef03e9d7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 17 Apr 2024 16:16:56 +0200 Subject: [PATCH 5/6] update docs to include import of countries which is necessary to be able to import addresses --- docs/source/installation/load-addresses.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/installation/load-addresses.rst b/docs/source/installation/load-addresses.rst index 779032fd0..85c29d618 100644 --- a/docs/source/installation/load-addresses.rst +++ b/docs/source/installation/load-addresses.rst @@ -8,6 +8,16 @@ Chill can store a list of geolocated address references, which are used to sugge Those addresses may be load from a dedicated source. +Countries +========= + +In order to load addresses into the chill application we first have to make sure that a list of countries is present. +To import the countries run the following command. + +.. code-block:: bash + + bin/console chill:main:countries:populate + In France ========= From ab6feef371eda7885bd6ab80967389fb754303ef Mon Sep 17 00:00:00 2001 From: juminet Date: Thu, 18 Apr 2024 07:37:05 +0000 Subject: [PATCH 6/6] Do not display evaluation from closed accompanying period on homepage --- .changes/unreleased/Fixed-20240416-161817.yaml | 6 ++++++ .../AccompanyingPeriodWorkEvaluationRepository.php | 3 +++ 2 files changed, 9 insertions(+) create mode 100644 .changes/unreleased/Fixed-20240416-161817.yaml diff --git a/.changes/unreleased/Fixed-20240416-161817.yaml b/.changes/unreleased/Fixed-20240416-161817.yaml new file mode 100644 index 000000000..6884c11fe --- /dev/null +++ b/.changes/unreleased/Fixed-20240416-161817.yaml @@ -0,0 +1,6 @@ +kind: Fixed +body: Fix broken link in homepage when a evaluation from a closed acc period was present + in the homepage widget +time: 2024-04-16T16:18:17.888645172+02:00 +custom: + Issue: "270" diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php index 9c6ed19fc..6110f8bb0 100644 --- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationRepository.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Repository\AccompanyingPeriod; use Chill\MainBundle\Entity\User; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWorkEvaluation; use Doctrine\ORM\EntityManagerInterface; @@ -88,6 +89,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->where( $qb->expr()->andX( $qb->expr()->isNull('e.endDate'), + $qb->expr()->neq('period.step', ':closed'), $qb->expr()->gte(':now', $qb->expr()->diff('e.maxDate', 'e.warningInterval')), $qb->expr()->orX( $qb->expr()->eq('period.user', ':user'), @@ -100,6 +102,7 @@ class AccompanyingPeriodWorkEvaluationRepository implements ObjectRepository ->setParameters([ 'user' => $user, 'now' => new \DateTimeImmutable('now'), + 'closed' => AccompanyingPeriod::STEP_CLOSED, ]); return $qb;