codeburn/app/renderer/lib/reportMemoKey.ts
Aditya Vikram Singh b5f07d1cc7
perf(desktop): keep every destination useful across restarts (#1163)
* perf(desktop): keep every destination useful across restarts

* fix(desktop): label cached reports while they refresh

* fix(desktop): preserve reviewed cache invariants

* fix(desktop): bound durable snapshot work
2026-08-28 14:51:18 -07:00

21 lines
775 B
TypeScript

import { localDateKey } from './period'
import type { DateRange, Period } from './types'
/** Identity for a durable report snapshot. Today and Month include the local
* calendar boundary so yesterday's exact answer can never paint under today's
* label after midnight; rolling/historical horizons remain reusable. */
export function reportMemoKey(
section: string,
period: Period,
provider = 'all',
range: DateRange | null = null,
variant = '',
now = new Date(),
): string {
const boundary = period === 'today'
? localDateKey(now)
: period === 'month'
? `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`
: ''
return `${section}|${period}|${provider}|${range?.from ?? ''}-${range?.to ?? ''}|${variant}|${boundary}`
}