diff --git a/api/resolvers/user.js b/api/resolvers/user.js index 92498131..7449eaf0 100644 --- a/api/resolvers/user.js +++ b/api/resolvers/user.js @@ -570,6 +570,10 @@ 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}` + return max + }, nitems: async (user, { when }, { models }) => { if (typeof user.nitems === 'number') { return user.nitems diff --git a/api/typeDefs/user.js b/api/typeDefs/user.js index 87f2a3dd..327ea9f9 100644 --- a/api/typeDefs/user.js +++ b/api/typeDefs/user.js @@ -62,6 +62,7 @@ export default gql` bioId: Int photoId: Int streak: Int + maxStreak: Int sats: Int! since: Int upvotePopover: Boolean! diff --git a/components/user-header.js b/components/user-header.js index d6b32169..11a874bf 100644 --- a/components/user-header.js +++ b/components/user-header.js @@ -50,7 +50,7 @@ export default function UserHeader ({ user }) { return ( <>
-
+
click or scan
- stacking since: {user.since - ? #{user.since} - : never} - +
+ stacking since: {user.since + ? #{user.since} + : never} + + longest cowboy streak: {user.maxStreak !== null ? user.maxStreak : 'none'} +