Skip to content

Commit cd2ff0f

Browse files
authored
Merge branch 'main' into feat/literalis-wfs-communication
2 parents e180f04 + 743bb7a commit cd2ff0f

File tree

25 files changed

+775
-7
lines changed

25 files changed

+775
-7
lines changed

assets/controllers/stats_map_controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ let cachedOrganizationsData = null;
88

99
// Configuration des territoires d'outre-mer
1010
const OVERSEAS_TERRITORIES = [
11-
{ name: 'Guadeloupe', center: [-61.55, 16.25], zoom: 8.5 },
12-
{ name: 'Martinique', center: [-61.02, 14.64], zoom: 9 },
11+
{ name: 'Guadeloupe', center: [-61.55, 16.25], zoom: 7.5 },
12+
{ name: 'Martinique', center: [-61.02, 14.64], zoom: 8 },
1313
{ name: 'Guyane', center: [-53.13, 3.93], zoom: 5 },
14-
{ name: 'La Réunion', center: [55.536, -21.115], zoom: 8 },
15-
{ name: 'Mayotte', center: [45.166244, -12.8275], zoom: 10 },
14+
{ name: 'La Réunion', center: [55.536, -21.115], zoom: 7.5 },
15+
{ name: 'Mayotte', center: [45.166244, -12.8275], zoom: 8 },
1616
];
1717

1818
// Bounding box de la France métropolitaine

docs/tools/metabase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Le Metabase de DiaLog est hébergé sur Scalingo sous l'application `dialog-meta
1212

1313
Cette application dispose de sa propre base de données où nous stockons les données nécessaires au calcul des indicateurs, conformément aux [recommendations Beta](https://doc.incubateur.net/communaute/les-outils-de-la-communaute/autres-services/metabase/metabase#connecter-metabase-a-une-base-de-donnees-anonymisee)
1414

15-
La collecte des données d'indicateurs est réalisée au moyen d'une la commande Symfony `app:metabase:export`. Cette commande rassemble les données sources (requêtes à la base de données, requêtes HTTP, ou autres opérations...) puis les upload vers la base de données PostgreSQL de l'instance Metabase.
15+
La collecte des données d'indicateurs est réalisée au moyen d'une la commande Symfony `app:metabase:export`. Cette commande rassemble les données sources (requêtes à la base de données, requêtes HTTP, ou autres opérations...) puis les upload vers la base de données PostgreSQL de l'instance Metabase.
1616

1717
## Lancer l'export depuis GitHub Actions
1818

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Application\Statistics\Command;
6+
7+
use App\Application\CommandInterface;
8+
9+
final class RecordApiUsageCommand implements CommandInterface
10+
{
11+
public function __construct(
12+
public readonly string $type,
13+
) {
14+
}
15+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Application\Statistics\Command;
6+
7+
use App\Application\DateUtilsInterface;
8+
use App\Application\IdFactoryInterface;
9+
use App\Domain\Statistics\ApiUsageDaily;
10+
use App\Domain\Statistics\Repository\ApiUsageDailyRepositoryInterface;
11+
12+
final class RecordApiUsageCommandHandler
13+
{
14+
public function __construct(
15+
private readonly ApiUsageDailyRepositoryInterface $apiUsageDailyRepository,
16+
private readonly DateUtilsInterface $dateUtils,
17+
private readonly IdFactoryInterface $idFactory,
18+
) {
19+
}
20+
21+
public function __invoke(RecordApiUsageCommand $command): void
22+
{
23+
$day = $this->dateUtils->getNow()->setTime(0, 0, 0);
24+
$existing = $this->apiUsageDailyRepository->findOneByDayAndType($day, $command->type);
25+
26+
if ($existing) {
27+
$existing->setCount($existing->getCount() + 1);
28+
} else {
29+
$this->apiUsageDailyRepository->add(new ApiUsageDaily(
30+
uuid: $this->idFactory->make(),
31+
day: $day,
32+
type: $command->type,
33+
count: 1,
34+
));
35+
}
36+
}
37+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Domain\Statistics;
6+
7+
class ApiUsageDaily
8+
{
9+
public function __construct(
10+
private string $uuid,
11+
private \DateTimeInterface $day,
12+
private string $type,
13+
private int $count = 0,
14+
private ?\DateTimeInterface $exportedAt = null,
15+
) {
16+
}
17+
18+
public function getUuid(): string
19+
{
20+
return $this->uuid;
21+
}
22+
23+
public function getDay(): \DateTimeInterface
24+
{
25+
return $this->day;
26+
}
27+
28+
public function getType(): string
29+
{
30+
return $this->type;
31+
}
32+
33+
public function getCount(): int
34+
{
35+
return $this->count;
36+
}
37+
38+
public function setCount(int $count): void
39+
{
40+
$this->count = $count;
41+
}
42+
43+
public function getExportedAt(): ?\DateTimeInterface
44+
{
45+
return $this->exportedAt;
46+
}
47+
48+
public function setExportedAt(?\DateTimeInterface $exportedAt): void
49+
{
50+
$this->exportedAt = $exportedAt;
51+
}
52+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Domain\Statistics\Repository;
6+
7+
use App\Domain\Statistics\ApiUsageDaily;
8+
9+
interface ApiUsageDailyRepositoryInterface
10+
{
11+
public function findOneByDayAndType(\DateTimeInterface $day, string $type): ?ApiUsageDaily;
12+
13+
/**
14+
* @return ApiUsageDaily[]
15+
*/
16+
public function findNotExportedUntil(\DateTimeInterface $until): array;
17+
18+
public function add(ApiUsageDaily $apiUsageDaily): void;
19+
20+
public function flush(): void;
21+
}

src/Domain/Statistics/Repository/StatisticsRepositoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ public function addUserActiveStatistics(\DateTimeImmutable $now): void;
1313
public function addOrganizationExtractStatistics(\DateTimeImmutable $now): void;
1414

1515
public function addRegulationOrderRecordsExtractStatistics(\DateTimeImmutable $now): void;
16+
17+
public function addApiUsageStatistics(\DateTimeImmutable $now): void;
1618
}

src/Infrastructure/Adapter/BdTopoRoadGeocoder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public function findNamedStreets(string $search, string $cityCode): array
143143

144144
public function findRoads(string $search, string $roadType, string $administrator): array
145145
{
146+
$administrator = ucfirst($administrator);
147+
146148
// Can search for a departmental road with the prefix "RD"
147149
if (str_starts_with(strtoupper($search), 'RD')) {
148150
$search = substr($search, 1);
@@ -188,6 +190,7 @@ public function findRoads(string $search, string $roadType, string $administrato
188190
public function computeRoad(string $roadType, string $administrator, string $roadNumber): string
189191
{
190192
$numero = strtoupper($roadNumber);
193+
$administrator = ucfirst($administrator);
191194
$typeDeRoute = $roadType === RoadTypeEnum::DEPARTMENTAL_ROAD->value ? 'Départementale' : 'Nationale';
192195

193196
try {
@@ -225,6 +228,8 @@ public function computeRoad(string $roadType, string $administrator, string $roa
225228

226229
public function findReferencePoints(string $search, string $administrator, string $roadNumber): array
227230
{
231+
$administrator = ucfirst($administrator);
232+
228233
try {
229234
$rows = $this->bdtopo2025Connection->fetchAllAssociative(
230235
'SELECT
@@ -278,6 +283,8 @@ public function computeReferencePoint(
278283
string $side,
279284
int $abscissa,
280285
): Coordinates {
286+
$administrator = ucfirst($administrator);
287+
281288
try {
282289
// Pour trouver un PR+abs, on trouve le PR, puis on remonte sa section de point de repère d'une distance indiquée par :abscissa.
283290
$row = $this->bdtopo2025Connection->fetchAssociative(
@@ -427,6 +434,8 @@ public function computeReferencePoint(
427434

428435
public function findSides(string $administrator, string $roadNumber, ?string $departmentCode, string $pointNumber): array
429436
{
437+
$administrator = ucfirst($administrator);
438+
430439
try {
431440
$rows = $this->bdtopo2025Connection->fetchAllAssociative(
432441
\sprintf(

src/Infrastructure/Adapter/LineSectionMaker.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function computeSection(
2626
int|float $tolerance = 1, // Meters
2727
): string {
2828
$includeCrs = str_contains($lineGeometry, '"crs"');
29-
3029
$pointA = $fromCoords->asGeoJSON($includeCrs);
3130
$pointB = $toCoords->asGeoJSON($includeCrs);
3231

src/Infrastructure/Integration/Litteralis/LitteralisPeriodParser.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ final class LitteralisPeriodParser
1616
// * 'de 08 h 00 à 18 h 00'
1717
// * '7 h 30 à 17 h 00'
1818
// * 'DE 7 H 30 à 17 H 00'
19+
// * 'DE 8H00 A 17H00' (Mandelieu : "A" au lieu de "à")
1920
// * '19h à 7h'
2021
// * 'de 21h à 6h.'
2122
// * 'de 8 heures à 15 heures 30'
22-
private const HOURS_REGEX = '/^(?:la nuit |de nuit )?(?:de )?(?P<startHour>\d{1,2}) ?(?:h|heures?) ?(?P<startMinute>\d{1,2})? (?:à|À|0) ?(?P<endHour>\d{1,2}) ?(?:h|heures?) ?(?P<endMinute>\d{1,2})?\.?$/i';
23+
private const HOURS_REGEX = '/^(?:la nuit |de nuit )?(?:de )?(?P<startHour>\d{1,2}) ?(?:h|heures?) ?(?P<startMinute>\d{1,2})? (?:à|À|0|[aA]) ?(?P<endHour>\d{1,2}) ?(?:h|heures?) ?(?P<endMinute>\d{1,2})?\.?$/i';
2324
private const ALL_HOURS_VALUES = [
2425
// <<< Litteralis Corrèze (aka CD19)
2526
'24/24 7j/7j',

0 commit comments

Comments
 (0)