mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-23 08:50:27 +01:00
instead of updating counters one by one on each topic move, update them once after all topics are moved, use zcard instead of incr/decr
This commit is contained in:
committed by
GitHub
parent
01669fa54e
commit
5607e5bccb
@@ -188,6 +188,20 @@ module.exports = function (Categories) {
|
||||
await Categories.updateRecentTidForCid(cid);
|
||||
};
|
||||
|
||||
Categories.onTopicsMoved = async (cids) => {
|
||||
await Promise.all(cids.map(async (cid) => {
|
||||
await Promise.all([
|
||||
Categories.setCategoryField(
|
||||
cid, 'topic_count', await db.sortedSetCard(`cid:${cid}:tids:lastposttime`)
|
||||
),
|
||||
Categories.setCategoryField(
|
||||
cid, 'post_count', await db.sortedSetCard(`cid:${cid}:pids`)
|
||||
),
|
||||
Categories.updateRecentTidForCid(cid),
|
||||
]);
|
||||
}));
|
||||
};
|
||||
|
||||
async function filterScheduledTids(tids) {
|
||||
const scores = await db.sortedSetScores('topics:scheduled', tids);
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user