fix(vigilance): écheance dynamique selon l'heure courante
Some checks are pending
Deploy info-canicule / deploy (push) Waiting to run

Le bulletin MF est publié 2× par jour (~6h et ~16h Paris). Pendant la nuit
(de minuit au prochain bulletin ~6h), on est techniquement dans le J+1 du
bulletin courant, qui correspond pour l'utilisateur à "aujourd'hui réel".

Avant : on affichait toujours J → la nuit, la carte montrait les alertes
"d'hier" alors que l'utilisateur cherche "celles d'aujourd'hui réel".
Symptôme : Florian voit du orange sur vigilance.meteofrance.fr (qui prend
la bonne écheance) mais pas chez nous (qui restait collé sur J).

Fix :
- currentEcheance(snapshot) compare now au end_time du J : si dépassé, J1.
- index.astro + departement.astro utilisent cette écheance pour
  "aujourd'hui". Page dept : "demain" = J1 si on est sur J, vide sinon.
- Labels rendus dynamiques : "Niveau par département — mardi 26 mai" au
  lieu de "(aujourd'hui)" générique.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Florian 2026-05-26 02:22:19 +02:00
parent 27441cdbb8
commit 0b418bd031
3 changed files with 69 additions and 12 deletions

View file

@ -4,7 +4,7 @@ import FranceMap from '../components/FranceMap.astro';
import DepartementGrid from '../components/DepartementGrid.astro';
import VigilanceLegend from '../components/VigilanceLegend.astro';
import VigilanceChip from '../components/VigilanceChip.astro';
import { getVigilanceSnapshot, maxColorByDepartement, activeAlerts } from '../lib/vigilance';
import { getVigilanceSnapshot, maxColorByDepartement, activeAlerts, currentEcheance } from '../lib/vigilance';
import { getDepartement } from '../lib/departements';
import type { VigilanceAlert } from '../lib/vigilance';
@ -18,14 +18,18 @@ try {
error = (e as Error).message;
}
const colorsByDept = snapshot ? maxColorByDepartement(snapshot, 'J') : new Map();
const alertsToday = snapshot ? activeAlerts(snapshot, 2) : [];
// Determine l'écheance "aujourd'hui réel" — peut être J ou J1 selon l'heure
// (entre minuit et la publication du bulletin suivant ~6h, J du bulletin = hier).
const ech = snapshot ? currentEcheance(snapshot) : 'J';
const colorsByDept = snapshot ? maxColorByDepartement(snapshot, ech) : new Map();
const alertsToday = snapshot
? snapshot.alerts.filter((a) => a.echeance === ech && a.colorId >= 2)
: [];
// Group all today's alerts (any level) by department, for tooltip + active alerts list.
const alertsByDept = new Map<string, VigilanceAlert[]>();
if (snapshot) {
for (const a of snapshot.alerts) {
if (a.echeance !== 'J') continue;
if (a.echeance !== ech) continue;
if (a.colorId < 2) continue;
const list = alertsByDept.get(a.departement) ?? [];
list.push(a);
@ -53,6 +57,16 @@ const productDate = snapshot?.productDatetime
timeZone: 'Europe/Paris',
})
: 'inconnu';
// Date de validité de l'écheance affichée (pour clarifier au visiteur)
const dayLabel = (() => {
if (!snapshot) return '';
const sample = snapshot.alerts.find((a) => a.echeance === ech);
if (!sample) return '';
return new Date(sample.beginTime).toLocaleDateString('fr-FR', {
weekday: 'long', day: 'numeric', month: 'long', timeZone: 'Europe/Paris',
});
})();
---
<Base>
@ -63,7 +77,14 @@ const productDate = snapshot?.productDatetime
</h1>
<p class="mt-2 max-w-2xl text-slate-600">
Carte des alertes Vigilance par département, conseils officiels et numéros d'urgence.
Bulletin Météo France du <strong>{productDate}</strong> (heure de Paris).
{dayLabel && (
<>
Affichage pour <strong class="capitalize">{dayLabel}</strong>.
</>
)}
</p>
<p class="mt-1 text-xs text-slate-500">
Bulletin Météo France émis le {productDate} (heure de Paris).
</p>
</div>
</section>