adjust the kpi card minigraph to be limited by publish cutoff time

This commit is contained in:
Alberto-Audrix committed 2026-09-07 14:30:55 +07:00
1 parent 3ba6fed189
commit 155a24c7bd
3 files changed
+73 -10

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
/** Keep rows on or before the dashboard publish cutoff date (ISO `YYYY-MM-DD`). */
export function throughVisibleDate<T extends { date: string }>(
rows: T[],
visibleThrough: string | null | undefined
): T[] {
if (!visibleThrough) return rows;
return rows.filter((row) => row.date <= visibleThrough);
}
/** True when `date` is on or before the publish cutoff (or cutoff is unknown). */
export function isOnOrBeforeVisibleDate(
date: string | null | undefined,
visibleThrough: string | null | undefined
): boolean {
if (!date) return false;
if (!visibleThrough) return true;
return date <= visibleThrough;
}