small cleanup to postSummary

v1.18.x
barisusakli 11 years ago
parent 9312675a77
commit d97af5020a

@ -338,19 +338,15 @@ var async = require('async'),
results.topics = toObject('tid', results.topicsAndCategories.topics); results.topics = toObject('tid', results.topicsAndCategories.topics);
results.categories = toObject('cid', results.topicsAndCategories.categories); results.categories = toObject('cid', results.topicsAndCategories.categories);
for(var i=0; i<posts.length; ++i) { for (var i=0; i<posts.length; ++i) {
if (!utils.isNumber(results.indices[i])) { posts[i].index = utils.isNumber(results.indices[i]) ? parseInt(results.indices[i], 10) + 2 : 1;
posts[i].index = 1;
} else {
posts[i].index = parseInt(results.indices[i], 10) + 2;
}
} }
async.map(posts, function(post, next) { posts = posts.filter(function(post) {
if (parseInt(results.topics[post.tid].deleted, 10) === 1) { return parseInt(results.topics[post.tid].deleted, 10) !== 1;
return next(); });
}
async.map(posts, function(post, next) {
post.user = results.users[post.uid]; post.user = results.users[post.uid];
post.topic = results.topics[post.tid]; post.topic = results.topics[post.tid];
post.category = results.categories[post.topic.cid]; post.category = results.categories[post.topic.cid];
@ -376,17 +372,7 @@ var async = require('async'),
next(null, post); next(null, post);
}); });
}, function(err, posts) { }, callback);
if (err) {
return callback(err);
}
posts = posts.filter(function(post) {
return !!post;
});
callback(null, posts);
});
}); });
}); });
}; };

Loading…
Cancel
Save