Skip to content

Node.js based forum software built for the modern web

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

Barış Soner Uşaklıa0f5461860c5
diff --git a/src/topics/recent.js b/src/topics/recent.js
index 7b5fa00cf2..eb964d259a 100644
--- a/src/topics/recent.js
+++ b/src/topics/recent.js
@@ -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);