From 781d03442218bda7a02aea00dce8b28be8ff683c Mon Sep 17 00:00:00 2001 From: keyan Date: Mon, 28 Aug 2023 20:12:33 -0500 Subject: [PATCH] fix top cowboy nulls --- api/resolvers/user.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/resolvers/user.js b/api/resolvers/user.js index 37567abb..b7474772 100644 --- a/api/resolvers/user.js +++ b/api/resolvers/user.js @@ -117,9 +117,12 @@ export default { topCowboys: async (parent, { cursor }, { models, me }) => { const decodedCursor = decodeCursor(cursor) const users = await models.$queryRawUnsafe(` - SELECT users.*, floor(sum(msats_spent)/1000) as spent, - sum(posts) as nposts, sum(comments) as ncomments, sum(referrals) as referrals, - floor(sum(msats_stacked)/1000) as stacked + SELECT users.*, + coalesce(floor(sum(msats_spent)/1000),0) as spent, + coalesce(sum(posts),0) as nposts, + coalesce(sum(comments),0) as ncomments, + coalesce(sum(referrals),0) as referrals, + coalesce(floor(sum(msats_stacked)/1000),0) as stacked FROM users LEFT JOIN user_stats_days on users.id = user_stats_days.id WHERE NOT "hideFromTopUsers" AND NOT "hideCowboyHat" AND streak IS NOT NULL