Results backfill: ESPN dates are US-Eastern — fetch both candidates
The first heal attempt missed both matches: a 02:00 UTC kickoff files under the PREVIOUS day in ESPN's ?dates= param (ET-based), and the backfill skipped today's UTC date entirely. Now any started-but- forgotten fixture triggers fetches for its UTC date and the day before, covering the ET offset in both directions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -117,11 +117,16 @@ export function startScheduler(
|
|||||||
// look 'scheduled' (fresh DB, or results lost before persistence existed)
|
// look 'scheduled' (fresh DB, or results lost before persistence existed)
|
||||||
// gets its date-scoped ESPN scoreboard re-fetched and merged.
|
// gets its date-scoped ESPN scoreboard re-fetched and merged.
|
||||||
const resultsBackfill = async (): Promise<void> => {
|
const resultsBackfill = async (): Promise<void> => {
|
||||||
const today = dateUTC(new Date().toISOString());
|
const now = Date.now();
|
||||||
const dates = new Set<string>();
|
const dates = new Set<string>();
|
||||||
for (const f of state.allFixtures()) {
|
for (const f of state.allFixtures()) {
|
||||||
const d = dateUTC(f.kickoff);
|
const k = new Date(f.kickoff).getTime();
|
||||||
if (d < today && f.status === 'scheduled' && f.home.team && f.away.team) dates.add(d);
|
// 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) {
|
for (const date of dates) {
|
||||||
if (stopped) return;
|
if (stopped) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user