fix: sélectionner l'observation la plus proche (pas la plus récente) pour patches et horizons
Les subqueries de loadHorizonScores() et loadPatches() triaient par detected_at DESC, ce qui provoquait une contamination inter-zones : une ingestion récente de Guadeloupe avec des patches à ~189km de la Barbade écrasait les données locales pourtant plus proches. Aligner sur la logique de loadLatestScore() (ImpactScoreService) qui trie déjà par ST_Distance ASC — les 3 sources (score now, patches, horizons) utilisent maintenant la même observation de référence. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -121,7 +121,9 @@ class SpotScoreController extends AbstractController
|
|||||||
coastal_point cp3
|
coastal_point cp3
|
||||||
WHERE cp3.id = :spotId
|
WHERE cp3.id = :spotId
|
||||||
AND ST_Distance(o2.geometry::geography, cp3.geometry::geography) < 300000
|
AND ST_Distance(o2.geometry::geography, cp3.geometry::geography) < 300000
|
||||||
ORDER BY o2.detected_at DESC LIMIT 1
|
ORDER BY ST_Distance(o2.geometry::geography, cp3.geometry::geography) ASC,
|
||||||
|
o2.detected_at DESC
|
||||||
|
LIMIT 1
|
||||||
)
|
)
|
||||||
ORDER BY f.time_horizon ASC',
|
ORDER BY f.time_horizon ASC',
|
||||||
['spotId' => $spotId]
|
['spotId' => $spotId]
|
||||||
@@ -243,7 +245,9 @@ class SpotScoreController extends AbstractController
|
|||||||
coastal_point cp3
|
coastal_point cp3
|
||||||
WHERE cp3.id = :spotId
|
WHERE cp3.id = :spotId
|
||||||
AND ST_Distance(o2.geometry::geography, cp3.geometry::geography) < 300000
|
AND ST_Distance(o2.geometry::geography, cp3.geometry::geography) < 300000
|
||||||
ORDER BY o2.detected_at DESC LIMIT 1
|
ORDER BY ST_Distance(o2.geometry::geography, cp3.geometry::geography) ASC,
|
||||||
|
o2.detected_at DESC
|
||||||
|
LIMIT 1
|
||||||
)
|
)
|
||||||
) dump
|
) dump
|
||||||
WHERE cp.id = :spotId
|
WHERE cp.id = :spotId
|
||||||
|
|||||||
Reference in New Issue
Block a user