topics.getPids will return mainPid as well

v1.18.x
barisusakli 11 years ago
parent 523b3db3f1
commit a69973e7a7

@ -36,24 +36,15 @@ module.exports = function(Categories) {
}
updatePostCount(tid, oldCid, cid);
async.parallel({
mainPid: function(next) {
topics.getTopicField(tid, 'mainPid', next);
},
pids: function(next) {
topics.getPids(tid, next);
}
}, function(err, results) {
topics.getPids(tid, function(err, pids) {
if (err) {
return winston.error(err.message);
}
if (!results.mainPid && results.pids && !results.pids.length) {
if (pids && !pids.length) {
return;
}
var pids = [results.mainPid].concat(results.pids);
var keys = pids.map(function(pid) {
return 'post:' + pid;
});

@ -73,7 +73,7 @@ var winston = require('winston'),
ThreadTools.purge = function(tid, uid, callback) {
async.parallel({
topic: function(next) {
topics.getTopicFields(tid, ['cid', 'mainPid'], next);
topics.getTopicFields(tid, ['cid'], next);
},
pids: function(next) {
topics.getPids(tid, next);
@ -83,16 +83,9 @@ var winston = require('winston'),
return callback(err);
}
var pids = [];
if (results.topic.mainPid) {
pids = [results.topic.mainPid].concat(results.pids);
} else {
pids = results.pids;
}
async.parallel([
function(next) {
async.eachLimit(pids, 10, posts.purge, next);
async.eachLimit(results.pids, 10, posts.purge, next);
},
function(next) {
topics.purge(tid, next);

@ -182,7 +182,22 @@ module.exports = function(Topics) {
};
Topics.getPids = function(tid, callback) {
db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, callback);
async.parallel({
mainPid: function(next) {
Topics.getTopicField(tid, 'mainPid', next);
},
pids: function(next) {
db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, next);
}
}, function(err, results) {
if (err) {
return callback(err);
}
if (results.mainPid) {
results.pids = [results.mainPid].concat(results.pids);
}
callback(null, results.pids);
});
};
Topics.increasePostCount = function(tid, callback) {

Loading…
Cancel
Save