Fix maxStreak for users with running best streak (#356)
Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
7a4ba715e0
commit
8536660580
|
@ -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 }) => {
|
||||||
|
|
Loading…
Reference in New Issue