dont add tid to :tids:posts if its pinned

v1.18.x
Barış Soner Uşaklı 8 years ago
parent 61a58f2607
commit 805cacb2af

@ -111,7 +111,7 @@ module.exports = function (Categories) {
Categories.onNewPostMade = function (cid, pinned, postData, callback) {
if (!cid || !postData) {
return callback();
return setImmediate(callback);
}
async.parallel([
@ -123,17 +123,23 @@ module.exports = function (Categories) {
},
function (next) {
if (parseInt(pinned, 10) === 1) {
next();
} else {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
return setImmediate(next);
}
async.parallel([
function (next) {
db.sortedSetAdd('cid:' + cid + ':tids', postData.timestamp, postData.tid, next);
},
function (next) {
db.sortedSetIncrBy('cid:' + cid + ':tids:posts', 1, postData.tid, next);
}
], function (err) {
next(err);
});
},
function (next) {
Categories.updateRecentTid(cid, postData.tid, next);
},
function (next) {
db.sortedSetIncrBy('cid:' + cid + ':tids:posts', 1, postData.tid, next);
}
}
], callback);
};

@ -184,13 +184,13 @@ module.exports = function (Topics) {
async.parallel([
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:pinned', Date.now(), tid),
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids', tid),
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:posts', tid),
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:posts', tid)
], next);
} else {
async.parallel([
async.apply(db.sortedSetRemove, 'cid:' + topicData.cid + ':tids:pinned', tid),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', topicData.lastposttime, tid),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:posts', topicData.postcount, tid),
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:posts', topicData.postcount, tid)
], next);
}
}

Loading…
Cancel
Save