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
This commit is contained in:
Barış Soner Uşaklı
2024-04-02 11:32:41 -04:00
parent 6e0d6697c4
commit 3aae92341c

View File

@@ -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)