don't set and read from topic hash in parallel (#6831)

this was causing a test to fail, although very rarely
v1.18.x
Barış Soner Uşaklı 6 years ago committed by GitHub
parent 28f2144933
commit a0f5461860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -250,30 +250,26 @@ module.exports = function (Topics) {
};
Topics.updateLastPostTime = function (tid, lastposttime, callback) {
async.parallel([
async.waterfall([
function (next) {
async.waterfall([
function (next) {
Topics.getTopicFields(tid, ['cid', 'deleted', 'pinned'], next);
},
function (topicData, next) {
var tasks = [
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:lastposttime', lastposttime, tid),
];
if (parseInt(topicData.deleted, 10) !== 1) {
tasks.push(async.apply(Topics.updateRecent, tid, lastposttime));
}
if (parseInt(topicData.pinned, 10) !== 1) {
tasks.push(async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', lastposttime, tid));
}
async.series(tasks, next);
},
], next);
Topics.setTopicField(tid, 'lastposttime', lastposttime, next);
},
function (next) {
Topics.setTopicField(tid, 'lastposttime', lastposttime, next);
Topics.getTopicFields(tid, ['cid', 'deleted', 'pinned'], next);
},
function (topicData, next) {
var tasks = [
async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids:lastposttime', lastposttime, tid),
];
if (parseInt(topicData.deleted, 10) !== 1) {
tasks.push(async.apply(Topics.updateRecent, tid, lastposttime));
}
if (parseInt(topicData.pinned, 10) !== 1) {
tasks.push(async.apply(db.sortedSetAdd, 'cid:' + topicData.cid + ':tids', lastposttime, tid));
}
async.series(tasks, next);
},
], function (err) {
callback(err);

Loading…
Cancel
Save