From 9dfab510dc71be11f0f4984ee163315004cdb282 Mon Sep 17 00:00:00 2001 From: mantrakp04 Date: Mon, 1 Jun 2026 13:56:36 -0700 Subject: [PATCH] fix(metrics): align hourly query lower bound to start of UTC hour hourlySince used now-23h (partial first bucket, undercounting the oldest hourly point). Align to start of current UTC hour like loadHourlyUsers and the chart bucket loop so all 24 buckets are full and keys line up. --- apps/backend/src/app/api/latest/internal/metrics/route.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/backend/src/app/api/latest/internal/metrics/route.tsx b/apps/backend/src/app/api/latest/internal/metrics/route.tsx index 36867ef61..62336ef02 100644 --- a/apps/backend/src/app/api/latest/internal/metrics/route.tsx +++ b/apps/backend/src/app/api/latest/internal/metrics/route.tsx @@ -1425,7 +1425,11 @@ async function loadAnalyticsOverview( ORDER BY hour ASC `, query_params: { - hourlySince: formatClickhouseDateTimeParam(new Date(now.getTime() - 23 * 60 * 60 * 1000)), + hourlySince: formatClickhouseDateTimeParam((() => { + const latestHour = new Date(now); + latestHour.setUTCMinutes(0, 0, 0); + return new Date(latestHour.getTime() - 23 * 60 * 60 * 1000); + })()), since: formatClickhouseDateTimeParam(since), untilExclusive: formatClickhouseDateTimeParam(untilExclusive), projectId: tenancy.project.id,