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

v1.18.x
Julian Lam 8 years ago
parent 8fc6123230
commit 3022a1920b

@ -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);
},
};

@ -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);
},
};

@ -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) {

@ -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);
},
};

@ -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);
},
};

Loading…
Cancel
Save