feat: async3 upgrade (#7639)

* feat: async3 upgrade WIP

* fix: async.doWhilst

* fix: async early exit

* fix: psql doUntil

* fix: psql again
v1.18.x
Barış Soner Uşaklı 6 years ago committed by GitHub
parent 6cebc7f069
commit 4d9bc30d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -31,7 +31,7 @@
"dependencies": {
"ace-builds": "^1.2.9",
"archiver": "^3.0.0",
"async": "2.6.2",
"async": "3.0.0",
"autoprefixer": "^9.4.6",
"bcryptjs": "2.4.3",
"benchpressjs": "^1.2.5",

@ -187,9 +187,9 @@ Analytics.getDailyStatsForSet = function (set, day, numDays, callback) {
day.setDate(day.getDate() + 1); // set the date to tomorrow, because getHourlyStatsForSet steps *backwards* 24 hours to sum up the values
day.setHours(0, 0, 0, 0);
async.whilst(function () {
async.whilst(function (next) {
numDays -= 1;
return numDays + 1;
next(null, numDays + 1);
}, function (next) {
Analytics.getHourlyStatsForSet(set, day.getTime() - (1000 * 60 * 60 * 24 * numDays), 24, function (err, day) {
if (err) {

@ -45,8 +45,8 @@ exports.processSortedSet = function (setKey, process, options, callback) {
var done = false;
async.whilst(
function () {
return !done;
function (next) {
next(null, !done);
},
function (next) {
async.waterfall([
@ -99,8 +99,8 @@ exports.processArray = function (array, process, options, callback) {
var done = false;
async.whilst(
function () {
return !done;
function (next) {
next(null, !done);
},
function (next) {
var currentBatch = array.slice(start, start + batch);

@ -156,8 +156,8 @@ helpers.redirect = function (res, url) {
helpers.buildCategoryBreadcrumbs = function (cid, callback) {
var breadcrumbs = [];
async.whilst(function () {
return parseInt(cid, 10);
async.whilst(function (next) {
next(null, parseInt(cid, 10));
}, function (next) {
categories.getCategoryFields(cid, ['name', 'slug', 'parentCid', 'disabled', 'isSection'], function (err, data) {
if (err) {

@ -502,8 +502,8 @@ module.exports = function (db, module) {
.batchSize(options.batch);
async.whilst(
function () {
return !done;
function (next) {
next(null, !done);
},
function (next) {
async.waterfall([

@ -707,14 +707,19 @@ SELECT z."value", z."score"
WHERE o."_key" = $1::TEXT
ORDER BY z."score" ASC, z."value" ASC`, [setKey]));
async.doUntil(function (next) {
var isDone = false;
async.whilst(function (next) {
next(null, !isDone);
}, function (next) {
query.read(batchSize, function (err, rows) {
if (err) {
return next(err);
}
if (!rows.length) {
return next(null, true);
isDone = true;
return next();
}
rows = rows.map(function (row) {
@ -735,8 +740,6 @@ SELECT z."value", z."score"
}
});
});
}, function (stop) {
return stop;
}, function (err) {
done();
callback(err);

@ -362,8 +362,8 @@ Messaging.hasPrivateChat = function (uid, withUid, callback) {
var index = 0;
var roomId = 0;
async.whilst(function () {
return index < roomIds.length && !roomId;
async.whilst(function (next) {
next(null, index < roomIds.length && !roomId);
}, function (next) {
Messaging.getUserCountInRoom(roomIds[index], function (err, count) {
if (err) {

@ -243,8 +243,8 @@ module.exports = function (Topics) {
},
], next);
},
function () {
return isDeleted && !done;
function (next) {
next(null, isDeleted && !done);
},
function (err) {
callback(err, parseInt(latestPid, 10));

@ -151,8 +151,8 @@ module.exports = function (Topics) {
next();
},
], next);
}, function () {
return isBlocked && prevPost && prevPost.pid && !checkedAllReplies;
}, function (next) {
next(null, isBlocked && prevPost && prevPost.pid && !checkedAllReplies);
}, function (err) {
callback(err, prevPost);
});

@ -298,8 +298,8 @@ module.exports = function (Topics) {
if (!params.blockedUids.length) {
return setImmediate(callback, null, hasUnblockedUnread);
}
async.whilst(function () {
return !done;
async.whilst(function (next) {
next(null, !done);
}, function (_next) {
async.waterfall([
function (next) {

@ -13,8 +13,8 @@ module.exports = {
return callback(err);
}
var currentChatRoomId = 1;
async.whilst(function () {
return currentChatRoomId <= nextChatRoomId;
async.whilst(function (next) {
next(null, currentChatRoomId <= nextChatRoomId);
}, function (next) {
db.getSortedSetRange('chat:room:' + currentChatRoomId + ':uids', 0, 0, function (err, uids) {
if (err) {

@ -18,8 +18,8 @@ module.exports = {
var roomId = globalData.nextChatRoomId || 1;
var currentMid = 1;
async.whilst(function () {
return currentMid <= globalData.nextMid;
async.whilst(function (next) {
next(null, currentMid <= globalData.nextMid);
}, function (next) {
db.getObject('message:' + currentMid, function (err, message) {
var msgTime;

@ -15,8 +15,8 @@ module.exports = {
return callback(err);
}
progress.total = nextUid;
async.whilst(function () {
return currentUid < nextUid;
async.whilst(function (next) {
next(null, currentUid < nextUid);
},
function (next) {
progress.incr();

@ -39,8 +39,8 @@ module.exports = {
var done = false;
async.whilst(
function () {
return !done;
function (next) {
next(null, !done);
},
function (next) {
async.waterfall([

@ -20,7 +20,7 @@ admin.get = function (callback) {
return callback(err);
}
callback(false, {
callback(null, {
templates: buildTemplatesFromAreas(widgetData.areas),
areas: widgetData.areas,
availableWidgets: widgetData.availableWidgets,

Loading…
Cancel
Save