From 8536660580f7734abfebbb4768636f05f9e5e117 Mon Sep 17 00:00:00 2001 From: ekzyis <27162016+ekzyis@users.noreply.github.com> Date: Fri, 14 Jul 2023 17:49:16 +0200 Subject: [PATCH] Fix maxStreak for users with running best streak (#356) Co-authored-by: ekzyis --- api/resolvers/user.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/resolvers/user.js b/api/resolvers/user.js index 7449eaf0..245d31db 100644 --- a/api/resolvers/user.js +++ b/api/resolvers/user.js @@ -571,7 +571,9 @@ export default { return item?.id }, 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 }, nitems: async (user, { when }, { models }) => {