From ba21c5170a37663305bfbb053174f4b035a9ea92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Thu, 11 Oct 2018 18:10:49 -0400 Subject: [PATCH] moved increase/decrease moved these two methods into addPostToTopic&removePostFromTopic --- src/topics/fork.js | 6 ------ src/topics/posts.js | 9 ++++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/topics/fork.js b/src/topics/fork.js index e1e3b51339..4ac4dfb113 100644 --- a/src/topics/fork.js +++ b/src/topics/fork.js @@ -108,12 +108,6 @@ module.exports = function (Topics) { function (next) { updateCategory(postData, tid, next); }, - function (next) { - Topics.decreasePostCount(postData.tid, next); - }, - function (next) { - Topics.increasePostCount(tid, next); - }, function (next) { posts.setPostField(pid, 'tid', tid, next); }, diff --git a/src/topics/posts.js b/src/topics/posts.js index eb31fc0171..7e1140e5fa 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -15,9 +15,6 @@ var utils = require('../../public/src/utils'); module.exports = function (Topics) { Topics.onNewPostMade = function (postData, callback) { async.series([ - function (next) { - Topics.increasePostCount(postData.tid, next); - }, function (next) { Topics.updateLastPostTime(postData.tid, postData.timestamp, next); }, @@ -287,6 +284,9 @@ module.exports = function (Topics) { }); } }, + function (next) { + Topics.increasePostCount(tid, next); + }, function (next) { db.sortedSetIncrBy('tid:' + tid + ':posters', 1, postData.uid, next); }, @@ -304,6 +304,9 @@ module.exports = function (Topics) { 'tid:' + tid + ':posts:votes', ], postData.pid, next); }, + function (next) { + Topics.decreasePostCount(tid, next); + }, function (next) { db.sortedSetIncrBy('tid:' + tid + ':posters', -1, postData.uid, next); },