This commit is contained in:
barisusakli
2014-09-16 21:43:11 -04:00
parent aae7f2434d
commit b48d81310c
5 changed files with 93 additions and 75 deletions

View File

@@ -2,27 +2,23 @@
var async = require('async'),
db = require('../database'),
batch = require('../batch'),
threadTools = require('../threadTools');
module.exports = function(Categories) {
Categories.purge = function(cid, callback) {
Categories.getTopicIds(cid, 0, -1, function(err, tids) {
batch.processSortedSet('categories:' + cid + ':tid', function(err, tids, next) {
if (err) {
return callback(err);
}
async.eachLimit(tids, 10, function(tid, next) {
threadTools.purge(tid, 0, next);
}, function(err) {
if (err) {
return callback(err);
}
purgeCategory(cid, callback);
});
}, next);
}, {alwaysStartAt: 0}, function(err) {
purgeCategory(cid, callback);
});
};
@@ -32,13 +28,7 @@ module.exports = function(Categories) {
db.sortedSetRemove('categories:cid', cid, next);
},
function(next) {
db.delete('categories:' + cid + ':tid', next);
},
function(next) {
db.delete('categories:recent_posts:cid:' + cid, next);
},
function(next) {
db.delete('category:' + cid, next);
db.deleteAll(['categories:' + cid + ':tid', 'categories:recent_posts:cid:' + cid, 'category:' + cid], next);
}
], callback);
}