This commit is contained in:
barisusakli
2014-06-17 13:11:09 -04:00
parent bbd4201a38
commit 7c84680b06
7 changed files with 107 additions and 60 deletions

View File

@@ -35,6 +35,8 @@ module.exports = function(Categories) {
], next);
}
updatePostCount(tid, oldCid, cid);
topics.getPids(tid, function(err, pids) {
if (err) {
return winston.error(err.message);
@@ -60,6 +62,25 @@ module.exports = function(Categories) {
});
});
};
function updatePostCount(tid, oldCid, newCid) {
topics.getTopicField(tid, 'postcount', function(err, postCount) {
if (err) {
return winston.error(err.message);
}
async.parallel([
function(next) {
db.incrObjectFieldBy('category:' + oldCid, 'post_count', -postCount, next);
},
function(next) {
db.incrObjectFieldBy('category:' + newCid, 'post_count', postCount, next);
}
], function(err) {
winston.error(err.message);
});
});
}
};