upgrade tags to sorted set

This commit is contained in:
barisusakli
2014-05-22 13:06:19 -04:00
parent 853acaa6c7
commit 746df87d89
7 changed files with 105 additions and 47 deletions

View File

@@ -27,28 +27,12 @@ tagsController.getTag = function(req, res, next) {
};
tagsController.getTags = function(req, res, next) {
topics.getTagsObjects(function(err, tags) {
topics.getTags(0, -1, function(err, tags) {
if (err) {
return next(err);
}
async.map(tags, function(tag, next) {
topics.getTagTopicCount(tag.name, function(err, count) {
if (err) {
return next(err);
}
tag.topicCount = count;
next(null, tag);
});
}, function(err, tags) {
if (err) {
return next(err);
}
tags = tags.sort(function(a, b) {
return parseInt(b.topicCount, 10) - parseInt(a.topicCount, 10);
});
res.render('tags', {tags: tags});
});
res.render('tags', {tags: tags});
});
};