mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
modify db.processSortedSet so it works with intervals
This commit is contained in:
@@ -467,13 +467,13 @@ module.exports = function (db, module) {
|
||||
}
|
||||
}
|
||||
|
||||
module.processSortedSet = function (setKey, process, batch, callback) {
|
||||
module.processSortedSet = function (setKey, process, options, callback) {
|
||||
var done = false;
|
||||
var ids = [];
|
||||
var cursor = db.collection('objects').find({ _key: setKey })
|
||||
.sort({ score: 1 })
|
||||
.project({ _id: 0, value: 1 })
|
||||
.batchSize(batch);
|
||||
.batchSize(options.batch);
|
||||
|
||||
async.whilst(
|
||||
function () {
|
||||
@@ -490,13 +490,20 @@ module.exports = function (db, module) {
|
||||
ids.push(item.value);
|
||||
}
|
||||
|
||||
if (ids.length < batch && (!done || ids.length === 0)) {
|
||||
if (ids.length < options.batch && (!done || ids.length === 0)) {
|
||||
return next(null);
|
||||
}
|
||||
|
||||
process(ids, function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
ids = [];
|
||||
return next(err);
|
||||
if (options.interval) {
|
||||
setTimeout(next, options.interval);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user