mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: filter followed tids by category
This commit is contained in:
@@ -177,9 +177,14 @@ module.exports = function (Topics) {
|
||||
}
|
||||
|
||||
async function getFollowedTids(params) {
|
||||
const tids = await db.getSortedSetsMembers(['uid:' + params.uid + ':followed_tids']);
|
||||
const scores = await db.sortedSetScores('topics:recent', tids[0]);
|
||||
const data = tids[0].map((tid, index) => ({ value: tid, score: scores[index] }));
|
||||
let tids = (await db.getSortedSetsMembers(['uid:' + params.uid + ':followed_tids']))[0];
|
||||
const filterCids = params.cid && params.cid.map(cid => parseInt(cid, 10));
|
||||
if (filterCids) {
|
||||
const topicData = await Topics.getTopicsFields(tids, ['tid', 'cid']);
|
||||
tids = topicData.filter(t => filterCids.includes(t.cid)).map(t => t.tid);
|
||||
}
|
||||
const scores = await db.sortedSetScores('topics:recent', tids);
|
||||
const data = tids.map((tid, index) => ({ value: tid, score: scores[index] }));
|
||||
return data.filter(item => item.score > params.cutoff);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user