Node.js based forum software built for the modern web
shorter getTeasers
barisusakli871cf8a3b7bc
diff --git a/src/posts/summary.js b/src/posts/summary.jsindex 5f7e5867de..463298f0c3 100644--- a/src/posts/summary.js+++ b/src/posts/summary.js@@ -16,7 +16,7 @@ var async = require('async'),module.exports = function(Posts) {Posts.getPostSummaryByPids = function(pids, uid, options, callback) {- if (!pids || !Array.isArray(pids) || !pids.length) {+ if (!Array.isArray(pids) || !pids.length) {return callback(null, []);}diff --git a/src/topics/teaser.js b/src/topics/teaser.jsindex 580c9a4615..0294159a81 100644--- a/src/topics/teaser.js+++ b/src/topics/teaser.js@@ -18,17 +18,8 @@ module.exports = function(Topics) {}async.parallel({- counts: function(next) {- Topics.getTopicsFields(tids, ['postcount'], function(err, topics) {- if (err) {- return next(err);- }- topics = topics.map(function(topic) {- return topic && (parseInt(topic.postcount, 10) || 0);- });-- next(null, topics);- });+ topics: function(next) {+ Topics.getTopicsFields(tids, ['postcount'], next);},pids: function(next) {async.map(tids, function(tid, next) {@@ -42,6 +33,10 @@ module.exports = function(Topics) {return callback(err);}+ var counts = results.topics.map(function(topic) {+ return topic && (parseInt(topic.postcount, 10) || 0);+ });+results.pids = results.pids.filter(Boolean);posts.getPostsFields(results.pids, ['pid', 'uid', 'timestamp', 'tid'], function(err, postData) {@@ -74,7 +69,7 @@ module.exports = function(Topics) {var teasers = tids.map(function(tid, index) {if (tidToPost[tid]) {- tidToPost[tid].index = results.counts[index];+ tidToPost[tid].index = counts[index];}return tidToPost[tid];});