mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
shorter getTeasers
This commit is contained in:
@@ -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];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user