Skip to content

Node.js based forum software built for the modern web

added progress bars to all upgrade scripts processing posts:pid sorted set

Julian Lam3022a1920bb8
diff --git a/src/upgrades/1.0.0/user_best_posts.js b/src/upgrades/1.0.0/user_best_posts.js
index a832a71254..560ef7b29c 100644
--- a/src/upgrades/1.0.0/user_best_posts.js
+++ b/src/upgrades/1.0.0/user_best_posts.js
@@ -12,6 +12,7 @@ module.exports = {
timestamp: Date.UTC(2016, 0, 14),
method: function (callback) {
var batch = require('../../batch');
+ var progress = this.progress;
batch.processSortedSet('posts:pid', function (ids, next) {
async.eachSeries(ids, function (id, next) {
@@ -24,8 +25,11 @@ module.exports = {
}
winston.verbose('processing pid: ' + postData.pid + ' uid: ' + postData.uid + ' votes: ' + postData.votes);
db.sortedSetAdd('uid:' + postData.uid + ':posts:votes', postData.votes, postData.pid, next);
+ progress.incr();
});
}, next);
- }, {}, callback);
+ }, {
+ progress: progress,
+ }, callback);
},
};
diff --git a/src/upgrades/1.1.0/separate_upvote_downvote.js b/src/upgrades/1.1.0/separate_upvote_downvote.js
index c397a36a7b..3f78667dc5 100644
--- a/src/upgrades/1.1.0/separate_upvote_downvote.js
+++ b/src/upgrades/1.1.0/separate_upvote_downvote.js
@@ -14,6 +14,8 @@ module.exports = {
var batch = require('../../batch');
var posts = require('../../posts');
var count = 0;
+ var progress = this.progress;
+
batch.processSortedSet('posts:pid', function (pids, next) {
winston.verbose('upgraded ' + count + ' posts');
count += pids.length;
@@ -43,8 +45,12 @@ module.exports = {
} else {
next();
}
+
+ progress.incr();
}, next);
}, next);
- }, {}, callback);
+ }, {
+ progress: progress,
+ }, callback);
},
};
diff --git a/src/upgrades/1.3.0/favourites_to_bookmarks.js b/src/upgrades/1.3.0/favourites_to_bookmarks.js
index 0888e69653..bbdc09ec4c 100644
--- a/src/upgrades/1.3.0/favourites_to_bookmarks.js
+++ b/src/upgrades/1.3.0/favourites_to_bookmarks.js
@@ -12,9 +12,12 @@ module.exports = {
method: function (callback) {
function upgradePosts(next) {
var batch = require('../../batch');
+ var progress = this.progress;
batch.processSortedSet('posts:pid', function (ids, next) {
async.each(ids, function (id, next) {
+ progress.incr();
+
async.waterfall([
function (next) {
db.rename('pid:' + id + ':users_favourited', 'pid:' + id + ':users_bookmarked', next);
@@ -34,7 +37,9 @@ module.exports = {
},
], next);
}, next);
- }, {}, next);
+ }, {
+ progress: progress,
+ }, next);
}
function upgradeUsers(next) {
diff --git a/src/upgrades/1.3.0/sorted_sets_for_post_replies.js b/src/upgrades/1.3.0/sorted_sets_for_post_replies.js
index b3ecd25f0a..1cce287829 100644
--- a/src/upgrades/1.3.0/sorted_sets_for_post_replies.js
+++ b/src/upgrades/1.3.0/sorted_sets_for_post_replies.js
@@ -13,12 +13,16 @@ module.exports = {
method: function (callback) {
var posts = require('../../posts');
var batch = require('../../batch');
+ var progress = this.progress;
+
batch.processSortedSet('posts:pid', function (ids, next) {
posts.getPostsFields(ids, ['pid', 'toPid', 'timestamp'], function (err, data) {
if (err) {
return next(err);
}
+ progress.incr();
+
async.eachSeries(data, function (postData, next) {
if (!parseInt(postData.toPid, 10)) {
return next(null);
@@ -30,6 +34,8 @@ module.exports = {
], next);
}, next);
});
+ }, {
+ progress: progress,
}, callback);
},
};
diff --git a/src/upgrades/1.5.0/flags_refactor.js b/src/upgrades/1.5.0/flags_refactor.js
index 7aff6bcfe7..08fc1831d8 100644
--- a/src/upgrades/1.5.0/flags_refactor.js
+++ b/src/upgrades/1.5.0/flags_refactor.js
@@ -13,6 +13,7 @@ module.exports = {
var batch = require('../../batch');
var posts = require('../../posts');
var flags = require('../../flags');
+ var progress = this.progress;
batch.processSortedSet('posts:pid', function (ids, next) {
posts.getPostsByPids(ids, 1, function (err, posts) {
@@ -80,10 +81,14 @@ module.exports = {
} else {
next(err);
}
+
+ progress.incr();
});
});
}, next);
});
+ }, {
+ progress: this.progress,
}, callback);
},
};