Skip to content

Commit

Permalink
Fix bugs with timezones and date formats
Browse files Browse the repository at this point in the history
  • Loading branch information
nlinnanen committed May 6, 2024
1 parent c90c62a commit d432d61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/analytics/timeseries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const getTimeSeriesData = async (): Promise<TimeSeriesData> => {
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
Expand Down
2 changes: 1 addition & 1 deletion src/server/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Guild, number>),
Expand Down

0 comments on commit d432d61

Please sign in to comment.