mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 05:55:48 +01:00
modify db.processSortedSet so it works with intervals
This commit is contained in:
11
src/batch.js
11
src/batch.js
@@ -30,17 +30,18 @@ exports.processSortedSet = function (setKey, process, options, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
options.batch = options.batch || DEFAULT_BATCH_SIZE;
|
||||
|
||||
// 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);
|
||||
return db.processSortedSet(setKey, process, options, callback);
|
||||
}
|
||||
|
||||
// custom done condition
|
||||
options.doneIf = typeof options.doneIf === 'function' ? options.doneIf : function () {};
|
||||
|
||||
var batch = options.batch || DEFAULT_BATCH_SIZE;
|
||||
var start = 0;
|
||||
var stop = batch;
|
||||
var stop = options.batch;
|
||||
var done = false;
|
||||
|
||||
async.whilst(
|
||||
@@ -60,8 +61,8 @@ exports.processSortedSet = function (setKey, process, options, callback) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
start += utils.isNumber(options.alwaysStartAt) ? options.alwaysStartAt : batch + 1;
|
||||
stop = start + batch;
|
||||
start += utils.isNumber(options.alwaysStartAt) ? options.alwaysStartAt : options.batch + 1;
|
||||
stop = start + options.batch;
|
||||
|
||||
if (options.interval) {
|
||||
setTimeout(next, options.interval);
|
||||
|
||||
Reference in New Issue
Block a user