feat: ETA côtier — transformer la map en outil de décision actionnable

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gwadaking
2026-04-03 18:42:21 -04:00
parent da7d62fa6a
commit 744f76f85e
6 changed files with 137 additions and 24 deletions

View File

@@ -64,13 +64,13 @@ class SpotScoreController extends AbstractController
/**
* Score à un instant précis (sans cache).
*
* @return array{value: int, level: string, distance: float|null, density: float|null, trend: string|null, computedAt: string}|null
* @return array{value: int, level: string, distance: float|null, density: float|null, trend: string|null, etaHours: int|null, computedAt: string}|null
*/
private function loadScoreAt(string $spotId, \DateTimeImmutable $at): ?array
{
$row = $this->connection->fetchAssociative(
'SELECT score, level, distance_to_nearest_sargassum AS distance,
density_estimate AS density, trend, timestamp AS computed_at
density_estimate AS density, trend, eta_hours, timestamp AS computed_at
FROM impact_score
WHERE coastal_point_id = :spotId AND timestamp <= :at
ORDER BY timestamp DESC LIMIT 1',
@@ -131,16 +131,17 @@ class SpotScoreController extends AbstractController
/**
* @param array<string, mixed> $row
* @return array{value: int, level: string, distance: float|null, density: float|null, trend: string|null, computedAt: string}
* @return array{value: int, level: string, distance: float|null, density: float|null, trend: string|null, etaHours: int|null, computedAt: string}
*/
private function formatScore(array $row): array
{
return [
'value' => (int) $row['score'],
'level' => $row['level'],
'distance' => $row['distance'] !== null ? (float) $row['distance'] : null,
'density' => $row['density'] !== null ? (float) $row['density'] : null,
'distance' => $row['distance'] !== null ? (float) $row['distance'] : null,
'density' => $row['density'] !== null ? (float) $row['density'] : null,
'trend' => $row['trend'],
'etaHours' => $row['eta_hours'] !== null ? (int) $row['eta_hours'] : null,
'computedAt' => $row['computed_at'],
];
}