mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
perf: dont load all followed tids on unread/recent?filter=watched
This commit is contained in:
@@ -49,7 +49,7 @@ module.exports = function (Topics) {
|
||||
tids = await Topics.filterWatchedTids(tids, params.uid);
|
||||
}
|
||||
} else if (params.filter === 'watched') {
|
||||
tids = await db.getSortedSetRevRange(`uid:${params.uid}:followed_tids`, 0, -1);
|
||||
tids = await getWatchedTopics(params);
|
||||
} else if (params.cids) {
|
||||
tids = await getCidTids(params);
|
||||
} else if (params.tags.length) {
|
||||
@@ -63,6 +63,17 @@ module.exports = function (Topics) {
|
||||
return tids;
|
||||
}
|
||||
|
||||
async function getWatchedTopics(params) {
|
||||
const sortSet = ['recent', 'old'].includes(params.sort) ? 'topics:recent' : `topics:${params.sort}`;
|
||||
const method = params.sort === 'old' ? 'getSortedSetIntersect' : 'getSortedSetRevIntersect';
|
||||
return await db[method]({
|
||||
sets: [sortSet, `uid:${params.uid}:followed_tids`],
|
||||
weights: [1, 0],
|
||||
start: 0,
|
||||
stop: meta.config.recentMaxTopics - 1,
|
||||
});
|
||||
}
|
||||
|
||||
async function getTagTids(params) {
|
||||
const sets = [
|
||||
params.sort === 'old' ?
|
||||
|
||||
Reference in New Issue
Block a user