simpler method for getting pids

v1.18.x
psychobunny 8 years ago
parent 86a8b8ab93
commit 5d9b6062d6

@ -480,25 +480,16 @@ Upgrade.upgrade = function (callback) {
} }
}, },
function (next) { function (next) {
thisSchemaDate = Date.UTC(2017, 1, 27); thisSchemaDate = Date.UTC(2017, 1, 28);
var schemaName = '[2017/2/27] New sorted set posts:votes'; var schemaName = '[2017/2/27] New sorted set posts:votes';
if (schemaDate < thisSchemaDate) { if (schemaDate < thisSchemaDate) {
updatesMade = true; updatesMade = true;
winston.verbose(schemaName); winston.verbose(schemaName);
db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) { require('./batch').processSortedSet('posts:pid', function (pids, next) {
if (err) { async.each(pids, function (pid, next) {
return next(err); async.each(pids, function (pid, next) {
}
async.eachSeries(cids, function (cid, next) {
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, -1, function (err, pids) {
if (err || !pids) {
return next(err);
}
async.each(pids, function(pid, next) {
db.getObjectFields('post:' + pid, ['upvotes', 'downvotes'], function (err, postData) { db.getObjectFields('post:' + pid, ['upvotes', 'downvotes'], function (err, postData) {
if (err || !postData) { if (err || !postData) {
return next(err); return next(err);
@ -508,8 +499,8 @@ Upgrade.upgrade = function (callback) {
db.sortedSetAdd('posts:votes', votes, pid, next); db.sortedSetAdd('posts:votes', votes, pid, next);
}); });
}, next); }, next);
}); }, next);
}, function (err) { }, {}, function (err) {
if (err) { if (err) {
return next(err); return next(err);
} }
@ -517,7 +508,6 @@ Upgrade.upgrade = function (callback) {
winston.info(schemaName + ' - done'); winston.info(schemaName + ' - done');
Upgrade.update(thisSchemaDate, next); Upgrade.update(thisSchemaDate, next);
}); });
});
} else { } else {
winston.info(schemaName + ' - skipped!'); winston.info(schemaName + ' - skipped!');
next(); next();

Loading…
Cancel
Save