From d432d6199b956e328419f7eb5914097f7d5bda41 Mon Sep 17 00:00:00 2001 From: Niklas Linnanen Date: Mon, 6 May 2024 17:36:58 +0000 Subject: [PATCH] Fix bugs with timezones and date formats --- src/analytics/timeseries.ts | 2 +- src/server/analytics.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analytics/timeseries.ts b/src/analytics/timeseries.ts index a987f85..2b75bfe 100644 --- a/src/analytics/timeseries.ts +++ b/src/analytics/timeseries.ts @@ -7,7 +7,7 @@ export const getTimeSeriesData = async (): Promise => { const data = await prisma.$queryRaw` WITH "PointsByDate" AS ( SELECT - DATE_TRUNC('day', "Entry"."createdAt") as "date", + DATE_TRUNC('day', "Entry"."createdAt" AT TIME ZONE 'EEST' ) as "date", "guild", SUM("earnedPoints") as "totalPoints" FROM diff --git a/src/server/analytics.ts b/src/server/analytics.ts index cde0b0a..48b352f 100644 --- a/src/server/analytics.ts +++ b/src/server/analytics.ts @@ -67,7 +67,7 @@ router.get("/time-series", async (req, res) => { const groupedSeries = _.groupBy(timeSeries, (e) => e.date); const guildsAsColumns = _.map(groupedSeries, (entries, date) => { return { - date, + date: entries[0].date.toISOString(), ...(Object.fromEntries( entries.map((e) => [e.guild, e.totalPoints]), ) as Record),