diff --git a/server/src/ingest/scheduler.ts b/server/src/ingest/scheduler.ts index 1ab8d7c..1823910 100644 --- a/server/src/ingest/scheduler.ts +++ b/server/src/ingest/scheduler.ts @@ -117,11 +117,16 @@ export function startScheduler( // look 'scheduled' (fresh DB, or results lost before persistence existed) // gets its date-scoped ESPN scoreboard re-fetched and merged. const resultsBackfill = async (): Promise => { - const today = dateUTC(new Date().toISOString()); + const now = Date.now(); const dates = new Set(); for (const f of state.allFixtures()) { - const d = dateUTC(f.kickoff); - if (d < today && f.status === 'scheduled' && f.home.team && f.away.team) dates.add(d); + const k = new Date(f.kickoff).getTime(); + // a started-but-forgotten fixture: kickoff is past, state still 'scheduled' + if (k > now - 2 * 60 * 60 * 1000 || f.status !== 'scheduled' || !f.home.team || !f.away.team) continue; + // ESPN's ?dates= is US-Eastern-based: a late-UTC kickoff files under the + // previous calendar day there — fetch both candidates + dates.add(dateUTC(f.kickoff)); + dates.add(dateUTC(new Date(k - 24 * 60 * 60 * 1000).toISOString())); } for (const date of dates) { if (stopped) return;