updated logic to make it a bit simpler to implement per upgrade script

This commit is contained in:
Julian Lam
2017-04-16 13:25:01 -04:00
parent 1cd50a8c30
commit 33082d90cc
4 changed files with 56 additions and 51 deletions

View File

@@ -21,6 +21,17 @@ exports.processSortedSet = function (setKey, process, options, callback) {
return callback(new Error('[[error:process-not-a-function]]'));
}
// Progress bar handling (upgrade scripts)
if (options.progress) {
db.sortedSetCard(setKey, function (err, total) {
if (err) {
// Unable to get total, do nothing.
} else {
options.progress.total = total;
}
});
}
// use the fast path if possible
if (db.processSortedSet && typeof options.doneIf !== 'function' && !utils.isNumber(options.alwaysStartAt)) {
return db.processSortedSet(setKey, process, options.batch || DEFAULT_BATCH_SIZE, callback);
@@ -53,6 +64,7 @@ exports.processSortedSet = function (setKey, process, options, callback) {
}
start += utils.isNumber(options.alwaysStartAt) ? options.alwaysStartAt : batch + 1;
stop = start + batch;
next();
});
});