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);
|
||||
},
|
||||
function (next) {
|
||||
async.each(privileges.privilegeList, function (privilege, next) {
|
||||
async.eachSeries(privileges.privilegeList, function (privilege, next) {
|
||||
groups.destroy('cid:' + cid + ':privileges:' + privilege, next);
|
||||
}, next);
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@ var async = require('async');
|
||||
var plugins = require('../plugins');
|
||||
var utils = require('../utils');
|
||||
var db = require('./../database');
|
||||
var batch = require('../batch');
|
||||
|
||||
module.exports = function (Groups) {
|
||||
Groups.destroy = function (groupName, callback) {
|
||||
@@ -30,14 +31,14 @@ module.exports = function (Groups) {
|
||||
async.apply(db.delete, 'group:' + groupName + ':owners'),
|
||||
async.apply(db.deleteObjectField, 'groupslug:groupname', utils.slugify(groupName)),
|
||||
function (next) {
|
||||
db.getSortedSetRange('groups:createtime', 0, -1, function (err, groups) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
async.each(groups, function (group, next) {
|
||||
db.sortedSetRemove('group:' + group + ':members', groupName, next);
|
||||
}, next);
|
||||
});
|
||||
batch.processSortedSet('groups:createtime', function (groupNames, next) {
|
||||
var keys = groupNames.map(function (group) {
|
||||
return 'group:' + group + ':members';
|
||||
});
|
||||
db.sortedSetsRemove(keys, groupName, next);
|
||||
}, {
|
||||
batch: 500,
|
||||
}, next);
|
||||
},
|
||||
], function (err) {
|
||||
if (err) {
|
||||
|
||||
Reference in New Issue
Block a user