From 08e3d21805b1f00d9da4d706b08d05d8c148c9e9 Mon Sep 17 00:00:00 2001 From: ymarcon Date: Wed, 30 Oct 2024 15:13:14 +0100 Subject: [PATCH] feat: stick time range requests to nearest hours --- frontend/src/stores/measures.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/src/stores/measures.ts b/frontend/src/stores/measures.ts index 31513ca..31a32db 100644 --- a/frontend/src/stores/measures.ts +++ b/frontend/src/stores/measures.ts @@ -15,7 +15,11 @@ export const useMeasuresStore = defineStore('measures', () => { watch(() => timeseriesStore.timeRange, async () => { const startDateRange = timeseriesStore.timeRange[0]; + startDateRange.setMinutes(0, 0, 0); const endDateRange = timeseriesStore.timeRange[1]; + endDateRange.setMinutes(0, 0, 0); + // Add one hour to round up to the nearest next hour + endDateRange.setHours(endDateRange.getHours() + 1); // Calculate the time range in hours const timeRangeHours = (endDateRange.getTime() - startDateRange.getTime()) / (1000 * 60 * 60); if (timeRangeHours < 7 * 24) {