Per-tier Met Office fallback + use the new Forecast key for hourly/3-hourly
Was: one Promise.all across all 3 Met Office endpoints, any single failure
threw and discarded ALL of it, falling back to Open-Meteo entirely -- even
though only the daily endpoint has ever been confirmed to work (only Spot
key configured; hourly/three-hourly may need the separate Forecast
subscription settings just gained a field for). So the display was very
possibly running on Open-Meteo for everything despite a working Met Office
key, silently.
Now: hourly, three-hourly and daily are fetched independently
(Promise.allSettled). hourly/three-hourly try met_office's new
forecast_api_key first (falling back to api_key if no separate Forecast
key is set); daily keeps using api_key (Spot), matching what's actually
confirmed live. Only the tiers that fail fall back to Open-Meteo -- and
Open-Meteo itself is now fetched lazily, once, only if at least one tier
actually needs it.
status.last_provider is now {hourly, threeHourly, daily} instead of one
flat string, so the admin page shows exactly which source served which
tier. Admin.tsx / types.ts updated to match.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
13fb30d9a3
commit
4b535a34f4
3 changed files with 164 additions and 112 deletions
|
|
@ -120,7 +120,11 @@ export default function Admin() {
|
|||
</div>
|
||||
<div className="wx-status-row">
|
||||
<span className="wx-status-label">Provider</span>
|
||||
<span className="wx-status-value">{status?.last_provider ?? '—'}</span>
|
||||
<span className="wx-status-value">
|
||||
{status?.last_provider
|
||||
? `hourly: ${status.last_provider.hourly ?? '—'} · 3-hourly: ${status.last_provider.threeHourly ?? '—'} · daily: ${status.last_provider.daily ?? '—'}`
|
||||
: '—'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="wx-status-row">
|
||||
<span className="wx-status-label">Status</span>
|
||||
|
|
|
|||
|
|
@ -29,6 +29,16 @@ export interface Summary {
|
|||
umbrella: boolean // real rain chance now or later today
|
||||
}
|
||||
|
||||
export type Provider = 'met_office' | 'open_meteo'
|
||||
|
||||
// Each tier is fetched (and can fall back to Open-Meteo) independently — see
|
||||
// backend/src/lib/weather-fetch.js. Not a single flat provider anymore.
|
||||
export interface TierProvider {
|
||||
hourly: Provider | null
|
||||
threeHourly: Provider | null
|
||||
daily: Provider | null
|
||||
}
|
||||
|
||||
export interface ForecastPayload {
|
||||
hourly: ForecastPoint[] // today, full day
|
||||
threeHourly: ForecastPoint[] // next 2 days
|
||||
|
|
@ -37,7 +47,7 @@ export interface ForecastPayload {
|
|||
summary: Summary | null // null only if there's no hourly data yet
|
||||
meta: {
|
||||
fetched_at: string | null
|
||||
provider: 'met_office' | 'open_meteo' | null
|
||||
provider: TierProvider | null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +62,7 @@ export interface DisplayConfig {
|
|||
|
||||
export interface AdminStatus {
|
||||
last_fetch_at: string | null
|
||||
last_provider: string | null
|
||||
last_provider: TierProvider | null
|
||||
last_error: string | null
|
||||
point_counts: { hourly: number; threeHourly: number; daily: number }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue