perf: spots/overview — 100+ requêtes individuelles → 1 requête cachée 30 min

Avant : SargassesMap faisait 1 appel /api/spots (API Platform) puis
N appels /api/spots/{id}/score (un par spot, ~100+ pour la Guadeloupe).

Après : un seul GET /api/spots/overview (LATERAL JOIN spots+scores)
avec Cache-Control: public, max-age=1800, stale-while-revalidate=300.

Les marqueurs colorés s'affichent immédiatement depuis la réponse unique ;
/api/spots/{id}/score n'est appelé qu'au clic sur un spot (SpotPanel).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gwadaking
2026-04-14 12:43:38 -04:00
parent 14d2acc39b
commit 83690b94ab
3 changed files with 63 additions and 22 deletions

View File

@@ -25,9 +25,9 @@ async function post(path, body) {
export const api = {
spots: {
list: () => get('/spots'),
get: (id) => get(`/spots/${id}`),
score: (id, at) => get(`/spots/${id}/score`, { at }),
overview: () => get('/spots/overview'), // tous les spots + score en 1 requête cachée
get: (id) => get(`/spots/${id}`),
score: (id, at) => get(`/spots/${id}/score`, { at }),
},
observations: {
list: (bbox, date, source) => get('/observations', { bbox, date, source }),