mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
perf: make unread faster if there are 60k+ unread topics
fixes https://community.nodebb.org/topic/18350/nodebb-slow-after-website-have-over-60k-topic
This commit is contained in:
@@ -198,7 +198,7 @@ module.exports = function (Topics) {
|
|||||||
}
|
}
|
||||||
const cids = params.cid || await getWatchedTrackedCids(params.uid);
|
const cids = params.cid || await getWatchedTrackedCids(params.uid);
|
||||||
const keys = cids.map(cid => `cid:${cid}:tids:lastposttime`);
|
const keys = cids.map(cid => `cid:${cid}:tids:lastposttime`);
|
||||||
return await db.getSortedSetRevRangeByScoreWithScores(keys, 0, -1, '+inf', params.cutoff);
|
return await db.getSortedSetRevRangeByScoreWithScores(keys, 0, 200, '+inf', params.cutoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getWatchedTrackedCids(uid) {
|
async function getWatchedTrackedCids(uid) {
|
||||||
@@ -217,7 +217,7 @@ module.exports = function (Topics) {
|
|||||||
params.cid.map(cid => `cid:${cid}:tids:lastposttime`) :
|
params.cid.map(cid => `cid:${cid}:tids:lastposttime`) :
|
||||||
'topics:recent';
|
'topics:recent';
|
||||||
|
|
||||||
const recentTopicData = await db.getSortedSetRevRangeByScoreWithScores(keys, 0, -1, '+inf', params.cutoff);
|
const recentTopicData = await db.getSortedSetRevRangeByScoreWithScores(keys, 0, 200, '+inf', params.cutoff);
|
||||||
const isFollowed = await db.isSortedSetMembers(`uid:${params.uid}:followed_tids`, recentTopicData.map(t => t.tid));
|
const isFollowed = await db.isSortedSetMembers(`uid:${params.uid}:followed_tids`, recentTopicData.map(t => t.tid));
|
||||||
return recentTopicData.filter((t, i) => isFollowed[i]);
|
return recentTopicData.filter((t, i) => isFollowed[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user