v1.18.x
psychobunny 8 years ago
parent 61eb7aa68b
commit d70ccb1868

@ -9,7 +9,13 @@ module.exports = function (Topics) {
count = parseInt(count, 10) || 20;
if (term === 'alltime') {
return getAllTimePopular(uid, count, callback);
return getAllTimePopular(uid, count, function (err, topics) {
if (err) {
return callback(err);
}
sortTiedTopicsByViews(topics, callback);
});
}
async.waterfall([
@ -19,6 +25,9 @@ module.exports = function (Topics) {
function (tids, next) {
getTopics(tids, uid, count, next);
},
function (topics, next) {
sortTiedTopicsByViews(topics, next);
},
], callback);
};
@ -48,4 +57,12 @@ module.exports = function (Topics) {
},
], callback);
}
function sortTiedTopicsByViews(topics, next) {
topics.sort(function (a, b) {
return parseInt(a.postcount) !== parseInt(b.postcount) ? 0 : parseInt(b.viewcount, 10) - parseInt(a.viewcount, 10);
});
next(null, topics);
}
};

Loading…
Cancel
Save