Skip to content

Node.js based forum software built for the modern web

feat: move upgrade script and make it shorter

Barış Soner Uşaklı60e7de0d1351
diff --git a/src/upgrades/1.15.3/category_tags.js b/src/upgrades/1.16.0/category_tags.js
similarity index 58%
rename from src/upgrades/1.15.3/category_tags.js
rename to src/upgrades/1.16.0/category_tags.js
index 15fc0c86ca..ae6e204908 100644
--- a/src/upgrades/1.15.3/category_tags.js
+++ b/src/upgrades/1.16.0/category_tags.js
@@ -10,17 +10,6 @@ module.exports = {
timestamp: Date.UTC(2020, 10, 23),
method: async function () {
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 async.eachSeries(tids, async function (tid) {
@@ -32,11 +21,9 @@ module.exports = {
if (tags.length) {
const cid = topicData.cid;
await async.eachSeries(tags, async function (tag) {
- const count = await categoryTagCount(cid, tag);
- if (count > 0) {
- await db.sortedSetAdd('cid:' + cid + ':tags', count, tag);
- await db.sortedSetAdd('cid:' + cid + ':tag:' + tag + ':topics', topicData.timestamp, tid);
- }
+ await db.sortedSetAdd('cid:' + cid + ':tag:' + tag + ':topics', topicData.timestamp, tid);
+ const count = await db.sortedSetCard('cid:' + cid + ':tag:' + tag + ':topics');
+ await db.sortedSetAdd('cid:' + cid + ':tags', count, tag);
});
}