From 894d02a19632fa7b5f73cc7796b79ce6b9ac93f7 Mon Sep 17 00:00:00 2001 From: k00b Date: Sat, 21 Sep 2024 14:58:25 -0500 Subject: [PATCH] allow top sorting by boost --- api/resolvers/item.js | 4 ++++ lib/constants.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/api/resolvers/item.js b/api/resolvers/item.js index 447a8003..6c452a27 100644 --- a/api/resolvers/item.js +++ b/api/resolvers/item.js @@ -105,6 +105,8 @@ const orderByClause = (by, me, models, type) => { return 'ORDER BY "Item".msats DESC' case 'zaprank': return topOrderByWeightedSats(me, models) + case 'boost': + return 'ORDER BY "Item".boost DESC' case 'random': return 'ORDER BY RANDOM()' default: @@ -378,6 +380,7 @@ export default { activeOrMine(me), nsfwClause(showNsfw), typeClause(type), + by === 'boost' && '"Item".boost > 0', whenClause(when || 'forever', table))} ${orderByClause(by, me, models, type)} OFFSET $4 @@ -421,6 +424,7 @@ export default { typeClause(type), whenClause(when, 'Item'), await filterClause(me, models, type), + by === 'boost' && '"Item".boost > 0', muteClause(me))} ${orderByClause(by || 'zaprank', me, models, type)} OFFSET $3 diff --git a/lib/constants.js b/lib/constants.js index 07ca03ac..76640fa2 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -62,7 +62,7 @@ export const ITEM_FILTER_THRESHOLD = 1.2 export const DONT_LIKE_THIS_COST = 1 export const COMMENT_TYPE_QUERY = ['comments', 'freebies', 'outlawed', 'borderland', 'all', 'bookmarks'] export const USER_SORTS = ['value', 'stacking', 'spending', 'comments', 'posts', 'referrals'] -export const ITEM_SORTS = ['zaprank', 'comments', 'sats'] +export const ITEM_SORTS = ['zaprank', 'comments', 'sats', 'boost'] export const SUB_SORTS = ['stacking', 'revenue', 'spending', 'posts', 'comments'] export const WHENS = ['day', 'week', 'month', 'year', 'forever', 'custom'] export const ITEM_TYPES_USER = ['all', 'posts', 'comments', 'bounties', 'links', 'discussions', 'polls', 'freebies', 'jobs', 'bookmarks']