Fix maxStreak for users with running best streak (#356)

Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
ekzyis 2023-07-14 17:49:16 +02:00 committed by GitHub
parent 7a4ba715e0
commit 8536660580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -571,7 +571,9 @@ export default {
return item?.id return item?.id
}, },
maxStreak: async (user, args, { models }) => { maxStreak: async (user, args, { models }) => {
const [{ max }] = await models.$queryRaw`SELECT MAX(COALESCE("endedAt", "startedAt") - "startedAt") FROM "Streak" WHERE "userId" = ${user.id}` const [{ max }] = await models.$queryRaw`
SELECT MAX(COALESCE("endedAt", (now() AT TIME ZONE 'America/Chicago')::date) - "startedAt")
FROM "Streak" WHERE "userId" = ${user.id}`
return max return max
}, },
nitems: async (user, { when }, { models }) => { nitems: async (user, { when }, { models }) => {