mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-01 21:30:30 +01:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user