mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-27 02:40:39 +01:00
closes #5708
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user