feat: closes #9845, sort by views

This commit is contained in:
Barış Soner Uşaklı
2021-09-28 11:13:56 -04:00
parent aa370310a1
commit 6399b42826
10 changed files with 44 additions and 3 deletions

View File

@@ -118,6 +118,7 @@ module.exports = function (Topics) {
old: sortOld,
posts: sortPopular,
votes: sortVotes,
views: sortViews,
};
const sortFn = sortMap[params.sort] || sortRecent;
@@ -156,6 +157,10 @@ module.exports = function (Topics) {
return b.viewcount - a.viewcount;
}
function sortViews(a, b) {
return b.viewcount - a.viewcount;
}
async function filterTids(tids, params) {
const { filter } = params;
const { uid } = params;