fix(climato): remettre TX en moyenne + fenêtres calendaires jusqu'à aujourd'hui
All checks were successful
Deploy info-canicule / deploy (push) Successful in 1m33s
All checks were successful
Deploy info-canicule / deploy (push) Successful in 1m33s
TX revient en moyenne inter-stations (comme TN/TM) ; la version MAX était une mauvaise piste. Les vues 7j/30j/1an sont désormais construites sur une plage calendaire fixe se terminant à aujourd'hui (heure Paris) : les jours sans données source (lag publication ~1-4j) apparaissent comme points nuls plutôt que de décaler la fenêtre vers le passé. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
759cda8ea9
commit
a1c6002756
2 changed files with 22 additions and 12 deletions
|
|
@ -54,9 +54,23 @@ let normales30: Array<{ tx: number | null; tn: number | null }> = [];
|
|||
let normales365: Array<{ tx: number | null; tn: number | null }> = [];
|
||||
let normaleHourly: { tx: number | null; tn: number | null } | null = null;
|
||||
|
||||
const last7 = climato?.days?.slice(-7) ?? [];
|
||||
const last30 = climato?.days?.slice(-30) ?? [];
|
||||
const last365 = climato?.days?.slice(-365) ?? [];
|
||||
// Build calendar-based windows ending at today (Paris time), filling missing days with nulls.
|
||||
// Source data has a ~1-4 day publication lag; the chart must still end at today.
|
||||
const _todayParis = new Intl.DateTimeFormat('sv', { timeZone: 'Europe/Paris' }).format(new Date());
|
||||
const _climaByDate = new Map((climato?.days ?? []).map((d) => [d.date, d]));
|
||||
function _buildRange(n: number) {
|
||||
const result = [];
|
||||
for (let i = n - 1; i >= 0; i--) {
|
||||
const d = new Date(_todayParis + 'T12:00:00Z'); // noon UTC to avoid DST drift
|
||||
d.setUTCDate(d.getUTCDate() - i);
|
||||
const dateStr = new Intl.DateTimeFormat('sv', { timeZone: 'Europe/Paris' }).format(d);
|
||||
result.push(_climaByDate.get(dateStr) ?? { date: dateStr, tn: null, tx: null, tm: null, rr: null, stations: 0 });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
const last7 = climato ? _buildRange(7) : [];
|
||||
const last30 = climato ? _buildRange(30) : [];
|
||||
const last365 = climato ? _buildRange(365) : [];
|
||||
|
||||
if (!drom) {
|
||||
if (climato?.days?.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue