From 72fb442f83ffec698e6fd45c1c794323e051b881 Mon Sep 17 00:00:00 2001 From: Lee Hansel Solevilla Date: Wed, 20 Nov 2024 18:57:07 +0800 Subject: [PATCH] refactor: user streak to include last view with timezone --- src/common/users.ts | 1 + src/schema/users.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/users.ts b/src/common/users.ts index cd2c58896..ca6a71496 100644 --- a/src/common/users.ts +++ b/src/common/users.ts @@ -42,6 +42,7 @@ export interface GQLUserStreak { total?: number; current: number; lastViewAt?: Date; + lastViewAtTz?: Date; userId: string; weekStart: DayOfWeek; } diff --git a/src/schema/users.ts b/src/schema/users.ts index b231cd646..9f80d8271 100644 --- a/src/schema/users.ts +++ b/src/schema/users.ts @@ -669,6 +669,7 @@ export const typeDefs = /* GraphQL */ ` total: Int current: Int lastViewAt: DateTime + lastViewAtTz: DateTime weekStart: Int } @@ -1204,7 +1205,8 @@ const getUserStreakQuery = async ( ...builder, queryBuilder: builder.queryBuilder .addSelect( - `(date_trunc('day', "${builder.alias}"."lastViewAt" at time zone COALESCE(u.timezone, 'utc'))::date) AS "lastViewAtTz"`, + `(date_trunc('day', "${builder.alias}"."lastViewAt" at time zone COALESCE(u.timezone, 'utc'))::date)`, + 'lastViewAtTz', ) .addSelect('u.id', 'userId') .addSelect('u.timezone', 'timezone')