mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: move upgrade script and make it shorter
This commit is contained in:
@@ -10,17 +10,6 @@ module.exports = {
|
|||||||
timestamp: Date.UTC(2020, 10, 23),
|
timestamp: Date.UTC(2020, 10, 23),
|
||||||
method: async function () {
|
method: async function () {
|
||||||
const progress = this.progress;
|
const progress = this.progress;
|
||||||
const cache = {};
|
|
||||||
async function categoryTagCount(cid, tag) {
|
|
||||||
if (cache[cid] && cache[cid][tag]) {
|
|
||||||
return cache[cid][tag];
|
|
||||||
}
|
|
||||||
const count = await db.sortedSetIntersectCard(
|
|
||||||
['cid:' + cid + ':tids:lastposttime', 'tag:' + tag + ':topics']
|
|
||||||
);
|
|
||||||
cache[cid] = cache[cid] || {};
|
|
||||||
cache[cid][tag] = count;
|
|
||||||
}
|
|
||||||
|
|
||||||
await batch.processSortedSet('topics:tid', async function (tids) {
|
await batch.processSortedSet('topics:tid', async function (tids) {
|
||||||
await async.eachSeries(tids, async function (tid) {
|
await async.eachSeries(tids, async function (tid) {
|
||||||
@@ -32,11 +21,9 @@ module.exports = {
|
|||||||
if (tags.length) {
|
if (tags.length) {
|
||||||
const cid = topicData.cid;
|
const cid = topicData.cid;
|
||||||
await async.eachSeries(tags, async function (tag) {
|
await async.eachSeries(tags, async function (tag) {
|
||||||
const count = await categoryTagCount(cid, tag);
|
await db.sortedSetAdd('cid:' + cid + ':tag:' + tag + ':topics', topicData.timestamp, tid);
|
||||||
if (count > 0) {
|
const count = await db.sortedSetCard('cid:' + cid + ':tag:' + tag + ':topics');
|
||||||
await db.sortedSetAdd('cid:' + cid + ':tags', count, tag);
|
await db.sortedSetAdd('cid:' + cid + ':tags', count, tag);
|
||||||
await db.sortedSetAdd('cid:' + cid + ':tag:' + tag + ':topics', topicData.timestamp, tid);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user