mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Merge branch 'master' into add-module-emploi
This commit is contained in:
@@ -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) {}
|
||||
|
||||
@@ -48,7 +48,7 @@ class PostalCodeFRFromOpenData
|
||||
fseek($tmpfile, 0);
|
||||
|
||||
$csv = Reader::createFromStream($tmpfile);
|
||||
$csv->setDelimiter(';');
|
||||
$csv->setDelimiter(',');
|
||||
$csv->setHeaderOffset(0);
|
||||
|
||||
foreach ($csv as $offset => $record) {
|
||||
@@ -63,23 +63,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((string) $record['_geopoint'])) {
|
||||
[$lat, $lon] = array_map(static fn ($el) => (float) trim($el), explode(',', (string) $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,
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user