From 3aae92341cf33d4a56bdcc144df3a7c05ba9872a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Tue, 2 Apr 2024 11:32:41 -0400 Subject: [PATCH] fix: change digest to use posts sorting first to use the new popular ranking algo. also fixes empty digests if there are no new topics created in the past 24 hours but there are topics with posts --- src/user/digest.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/user/digest.js b/src/user/digest.js index b07f54d1c3..61f4b2f12f 100644 --- a/src/user/digest.js +++ b/src/user/digest.js @@ -183,20 +183,23 @@ async function getTermTopics(term, uid) { start: 0, stop: 199, term: term, - sort: 'votes', + sort: 'posts', teaserPost: 'first', }); data.topics = data.topics.filter(topic => topic && !topic.deleted); - const top = data.topics.filter(t => t.votes > 0).slice(0, 10); - const topTids = top.map(t => t.tid); - const popular = data.topics - .filter(t => t.postcount > 1 && !topTids.includes(t.tid)) + .filter(t => t.postcount > 1) .sort((a, b) => b.postcount - a.postcount) .slice(0, 10); const popularTids = popular.map(t => t.tid); + const top = data.topics + .filter(t => t.votes > 0 && !popularTids.includes(t.tid)) + .sort((a, b) => b.votes - a.votes) + .slice(0, 10); + const topTids = top.map(t => t.tid); + const recent = data.topics .filter(t => !topTids.includes(t.tid) && !popularTids.includes(t.tid)) .sort((a, b) => b.lastposttime - a.lastposttime)