Node.js based forum software built for the modern web
perf: make unread faster if there are 60k+ unread topics
Barış Soner Uşaklıf53f1394bd9b
diff --git a/src/topics/unread.js b/src/topics/unread.jsindex e3f7483572..4875356949 100644--- a/src/topics/unread.js+++ b/src/topics/unread.js@@ -198,7 +198,7 @@ module.exports = function (Topics) {}const cids = params.cid || await getWatchedTrackedCids(params.uid);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) {@@ -217,7 +217,7 @@ module.exports = function (Topics) {params.cid.map(cid => `cid:${cid}:tids:lastposttime`) :'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));return recentTopicData.filter((t, i) => isFollowed[i]);}