Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: #12444 add uncategorized topics counted stats to separate sorted…
… set
- Loading branch information
Showing
3 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// REMOVE THIS PRIOR TO 4.0 ALPHA | ||
|
||
'use strict'; | ||
|
||
const db = require('../../database'); | ||
|
||
module.exports = { | ||
name: 'Fix topic sorted sets for uncategorized topics', | ||
timestamp: Date.UTC(2024, 2, 26), | ||
method: async function () { | ||
const props = ['views', 'posts', 'votes']; | ||
const { progress } = this; | ||
const tids = await db.getSortedSetMembers('cid:-1:tids'); | ||
progress.total = tids.length; | ||
|
||
const remove = []; | ||
const add = []; | ||
await Promise.all(props.map(async (prop) => { | ||
const set = `topics:${prop}`; | ||
const newSet = `topicsRemote:${prop}`; | ||
|
||
const scores = await db.sortedSetScores(set, tids); | ||
scores.forEach((score, idx) => { | ||
if (score !== null) { | ||
remove.push([set, tids[idx]]); | ||
add.push([newSet, score, tids[idx]]); | ||
} | ||
}); | ||
})); | ||
|
||
await Promise.all([ | ||
db.sortedSetRemoveBulk(remove), | ||
db.sortedSetAddBulk(add), | ||
]); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// REMOVE THIS PRIOR TO 4.0 ALPHA | ||
|
||
'use strict'; | ||
|
||
const db = require('../../database'); | ||
|