refactor: remove async.waterfall
parent
f35a0f430a
commit
222dccaf67
@ -1,27 +1,22 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
const async = require('async');
|
||||
|
||||
const groups = require('../../groups');
|
||||
const db = require('../../database');
|
||||
|
||||
module.exports = {
|
||||
name: 'Give deleted post viewing privilege to moderators on all categories',
|
||||
timestamp: Date.UTC(2018, 5, 8),
|
||||
method: function (callback) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, (err, cids) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
method: async function () {
|
||||
const { progress } = this;
|
||||
const cids = await db.getSortedSetRange('categories:cid', 0, -1);
|
||||
for (const cid of cids) {
|
||||
const uids = await db.getSortedSetRange(`group:cid:${cid}:privileges:moderate:members`, 0, -1);
|
||||
for (const uid of uids) {
|
||||
await groups.join(`cid:${cid}:privileges:posts:view_deleted`, uid);
|
||||
}
|
||||
progress.incr();
|
||||
}
|
||||
async.eachSeries(cids, (cid, next) => {
|
||||
async.waterfall([
|
||||
async.apply(db.getSortedSetRange.bind(db), `group:cid:${cid}:privileges:moderate:members`, 0, -1),
|
||||
function (uids, next) {
|
||||
async.eachSeries(uids, (uid, next) => groups.join(`cid:${cid}:privileges:posts:view_deleted`, uid, next), next);
|
||||
},
|
||||
], next);
|
||||
}, callback);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue