From ce8adb88a47767a1b2ece533dd59d9c8194c1877 Mon Sep 17 00:00:00 2001 From: Anton Roslund Date: Sat, 9 Aug 2025 16:33:49 +0200 Subject: [PATCH] Provide propper timestamps --- src/stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stats.js b/src/stats.js index e4458a8..5129c96 100644 --- a/src/stats.js +++ b/src/stats.js @@ -68,14 +68,14 @@ router.get('/messages-per-hour', async (req, res) => { const uniqueCounts = Object.fromEntries( Array.from({ length: hours }, (_, i) => { const hourTime = new Date(now.getTime() - (hours - 1 - i) * 60 * 60 * 1000); - const hourString = hourTime.toISOString().slice(0, 13); // YYYY-MM-DD HH + const hourString = hourTime.toISOString().slice(0, 13) + ":00:00.000Z"; // zero out the minutes and seconds return [hourString, 0]; }) ); // Populate actual message counts messages.forEach(({ created_at }) => { - const hourString = created_at.toISOString().slice(0, 13); // YYYY-MM-DD HH + const hourString = created_at.toISOString().slice(0, 13) + ":00:00.000Z"; // zero out the minutes and seconds uniqueCounts[hourString] = (uniqueCounts[hourString] ?? 0) + 1; });