Fix daily cache gap fill using UTC instead of local time

The gapStart date was constructed with T00:00:00.000Z (UTC midnight),
causing it to land hours before local midnight. In PDT this meant
the gap fill re-parsed a partial slice of the previous day, and the
upsert replaced the full day with that partial data, losing cost.

Bump DAILY_CACHE_VERSION to 3 to force cache rebuild.
This commit is contained in:
iamtoruk 2026-04-19 04:23:17 -07:00 committed by AgentSeal
parent 070a378160
commit e3395d241f
2 changed files with 6 additions and 2 deletions

View file

@ -352,7 +352,11 @@ program
}
const gapStart = c.lastComputedDate
? new Date(new Date(`${c.lastComputedDate}T00:00:00.000Z`).getTime() + MS_PER_DAY)
? new Date(
parseInt(c.lastComputedDate.slice(0, 4)),
parseInt(c.lastComputedDate.slice(5, 7)) - 1,
parseInt(c.lastComputedDate.slice(8, 10)) + 1
)
: new Date(todayStart.getTime() - BACKFILL_DAYS * MS_PER_DAY)
if (gapStart.getTime() <= yesterdayEnd.getTime()) {

View file

@ -4,7 +4,7 @@ import { mkdir, open, readFile, rename, unlink } from 'fs/promises'
import { homedir } from 'os'
import { join } from 'path'
export const DAILY_CACHE_VERSION = 2
export const DAILY_CACHE_VERSION = 3
const DAILY_CACHE_FILENAME = 'daily-cache.json'
export type DailyEntry = {