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:
@@ -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 }),
|
||||
|
||||
Reference in New Issue
Block a user