performance improvements

store parsed category description
removed mongo _key from returns
dont get category teaser for parent
This commit is contained in:
barisusakli
2015-10-18 18:30:17 -04:00
parent e2f590e0b4
commit 53d29e29af
6 changed files with 105 additions and 102 deletions

View File

@@ -69,7 +69,7 @@ categoriesController.list = function(req, res, next) {
if (category && Array.isArray(category.posts) && category.posts.length) {
category.teaser = {
url: nconf.get('relative_path') + '/topic/' + category.posts[0].topic.slug + '/' + category.posts[0].index,
timestampISO: category.posts[0].relativeTime
timestampISO: category.posts[0].timestamp
};
}
});
@@ -203,8 +203,11 @@ categoriesController.get = function(req, res, callback) {
});
},
function(categoryData, next) {
if (!categoryData.children.length) {
return next(null, categoryData);
}
var allCategories = [];
categories.flattenCategories(allCategories, [categoryData]);
categories.flattenCategories(allCategories, categoryData.children);
categories.getRecentTopicReplies(allCategories, req.uid, function(err) {
next(err, categoryData);
});