Skip to content

Commit 78b86f2

Browse files
committed
fix(metrics): correct dashboard week boundary to Saturday
The dashboard window ended on Sunday instead of Saturday, so mid-week it requested a different window than the email and missed the warmed cache key. Align the exclusive end to the most recent Saturday so the page matches the email window and hits the warm cache. Part of #1961 Signed-off-by: Alan Peixinho <alan.peixinho@profusion.mobi>
1 parent 5ef7b2b commit 78b86f2

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

dashboard/src/pages/Metrics/MetricsPage.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,8 @@ function LabsSection({ labs }: { labs: LabData[] }): JSX.Element {
551551
const getMetricsQueryParams = (
552552
activeDays: number,
553553
): { startDaysAgo: number; endDaysAgo: number } => {
554-
const today = new Date();
555-
const weekEndDaysAgo = (today.getUTCDay() + 1) % DAYS_IN_WEEK;
556-
const endDaysAgo = Math.max(weekEndDaysAgo - 1, 0);
557-
const startDaysAgo = endDaysAgo + activeDays;
558-
return { startDaysAgo, endDaysAgo };
554+
const endDaysAgo = (new Date().getUTCDay() + 1) % DAYS_IN_WEEK;
555+
return { startDaysAgo: endDaysAgo + activeDays, endDaysAgo };
559556
};
560557

561558
export const MetricsPage = (): JSX.Element => {

0 commit comments

Comments
 (0)