diff --git a/backend/src/lib/weather-fetch.js b/backend/src/lib/weather-fetch.js index 349e522..862c36f 100644 --- a/backend/src/lib/weather-fetch.js +++ b/backend/src/lib/weather-fetch.js @@ -42,6 +42,14 @@ function londonDateKey(isoTime) { function londonHour(isoTime) { return parseInt(new Date(isoTime).toLocaleString('en-GB', { timeZone: 'Europe/London', hour: '2-digit', hour12: false })) } +// The 3-hourly tier (tomorrow/day-after "Coming up" cards) drops the very early +// morning slots nobody's checking the display for. A threshold rather than an +// exact hour set — Met Office's feed is a fixed UTC-aligned 3-hour cadence, so +// its London-local hours shift by 1 across the BST/GMT change (right now, BST, +// that's 1/4/7/10/13/16/19/22; in winter it's 0/3/6/9/12/15/18/21). ">= 6" drops +// the same two earliest slots either way instead of matching zero points once +// the clocks change. +const THREE_HOURLY_MIN_HOUR = 6 // Pure date math, not derived from any provider response — "tomorrow"/"day after" // are always just today+1/+2 regardless of source, which is what lets each tier // below be fetched (and fall back) fully independently of the others. @@ -100,7 +108,7 @@ async function fetchMetOfficeHourly(lat, lon, apiKey) { async function fetchMetOfficeThreeHourly(lat, lon, apiKey, dayKeys) { const series = await fetchMetOfficeTimestep('three-hourly', lat, lon, apiKey) - const dayRows = series.filter(p => dayKeys.includes(londonDateKey(p.time))) + const dayRows = series.filter(p => dayKeys.includes(londonDateKey(p.time)) && londonHour(p.time) >= THREE_HOURLY_MIN_HOUR) const points = dayRows .map(p => ({ resolution: '3hourly', @@ -208,7 +216,7 @@ function openMeteoHourlyPoints(hourlyRows) { } function openMeteoThreeHourlyPoints(hourlyRows, dayKeys) { return hourlyRows - .filter(r => dayKeys.includes(r.dateKey) && r.hour % 3 === 0) + .filter(r => dayKeys.includes(r.dateKey) && r.hour % 3 === 0 && r.hour >= THREE_HOURLY_MIN_HOUR) .map(r => ({ resolution: '3hourly', ts: r.time,