Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: user streak to include last view with timezone #2471

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface GQLUserStreak {
total?: number;
current: number;
lastViewAt?: Date;
lastViewAtTz?: Date;
userId: string;
weekStart: DayOfWeek;
}
Expand Down
4 changes: 3 additions & 1 deletion src/schema/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ export const typeDefs = /* GraphQL */ `
total: Int
current: Int
lastViewAt: DateTime
lastViewAtTz: DateTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the both timezoned and utc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old one is just for backwards support. The one with timezone is for this PR: dailydotdev/apps#3832

weekStart: Int
}

Expand Down Expand Up @@ -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')
Expand Down
Loading