mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 11:11:04 +01:00
fix timeouts on category.purge when there are 20k groups
This commit is contained in:
@@ -58,7 +58,7 @@ module.exports = function (Categories) {
|
|||||||
], next);
|
], next);
|
||||||
},
|
},
|
||||||
function (next) {
|
function (next) {
|
||||||
async.each(privileges.privilegeList, function (privilege, next) {
|
async.eachSeries(privileges.privilegeList, function (privilege, next) {
|
||||||
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
|
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ var async = require('async');
|
|||||||
var plugins = require('../plugins');
|
var plugins = require('../plugins');
|
||||||
var utils = require('../utils');
|
var utils = require('../utils');
|
||||||
var db = require('./../database');
|
var db = require('./../database');
|
||||||
|
var batch = require('../batch');
|
||||||
|
|
||||||
module.exports = function (Groups) {
|
module.exports = function (Groups) {
|
||||||
Groups.destroy = function (groupName, callback) {
|
Groups.destroy = function (groupName, callback) {
|
||||||
@@ -30,14 +31,14 @@ module.exports = function (Groups) {
|
|||||||
async.apply(db.delete, 'group:' + groupName + ':owners'),
|
async.apply(db.delete, 'group:' + groupName + ':owners'),
|
||||||
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName)),
|
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName)),
|
||||||
function (next) {
|
function (next) {
|
||||||
db.getSortedSetRange('groups:createtime', 0, -1, function (err, groups) {
|
batch.processSortedSet('groups:createtime', function (groupNames, next) {
|
||||||
if (err) {
|
var keys = groupNames.map(function (group) {
|
||||||
return next(err);
|
return 'group:' + group + ':members';
|
||||||
}
|
|
||||||
async.each(groups, function (group, next) {
|
|
||||||
db.sortedSetRemove('group:' + group + ':members', groupName, next);
|
|
||||||
}, next);
|
|
||||||
});
|
});
|
||||||
|
db.sortedSetsRemove(keys, groupName, next);
|
||||||
|
}, {
|
||||||
|
batch: 500,
|
||||||
|
}, next);
|
||||||
},
|
},
|
||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user