mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-18 13:32:58 +01:00
Merge branch 'develop' into activitypub
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
"sorting.post-default": "Подредба по подразбиране на публикациите",
|
||||
"sorting.oldest-to-newest": "Първо най-старите",
|
||||
"sorting.newest-to-oldest": "Първо най-новите",
|
||||
"sorting.recently-replied": "Recently Replied",
|
||||
"sorting.recently-created": "Recently Created",
|
||||
"sorting.recently-replied": "Първо тези с най-скорошни отговори",
|
||||
"sorting.recently-created": "Първо най-скоро създадените",
|
||||
"sorting.most-votes": "Първо тези с най-много гласове",
|
||||
"sorting.most-posts": "Първо тези с най-много публикации",
|
||||
"sorting.most-views": "Most Views",
|
||||
"sorting.most-views": "Първо тези с най-много преглеждания",
|
||||
"sorting.topic-default": "Подредба по подразбиране на темите",
|
||||
"length": "Дължина на публикациите",
|
||||
"post-queue": "Опашка за публикации",
|
||||
|
||||
@@ -182,8 +182,8 @@
|
||||
"sort-by": "Подреждане по",
|
||||
"oldest-to-newest": "Първо най-старите",
|
||||
"newest-to-oldest": "Първо най-новите",
|
||||
"recently-replied": "Recently Replied",
|
||||
"recently-created": "Recently Created",
|
||||
"recently-replied": "Първо тези с най-скорошни отговори",
|
||||
"recently-created": "Първо най-скоро създадените",
|
||||
"most-votes": "Първо тези с най-много гласове",
|
||||
"most-posts": "Първо тези с най-много публикации",
|
||||
"most-views": "Първо тези с най-много преглеждания",
|
||||
|
||||
@@ -233,7 +233,7 @@ function hookHandlerPromise(hook, hookObj, params) {
|
||||
if (hook.startsWith('filter:') && returned !== undefined) {
|
||||
_resolve(returned);
|
||||
} else if (hook.startsWith('static:') && hookObj.method.length <= 1) {
|
||||
// make sure it is resolved if static hook doesn't return anything and doesn't use callback
|
||||
// make sure it is resolved if static hook doesn't use callback
|
||||
_resolve();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -59,15 +59,31 @@ module.exports = function (Topics) {
|
||||
tids = await getCidTids(params);
|
||||
} else if (params.tags.length) {
|
||||
tids = await getTagTids(params);
|
||||
} else if (params.sort === 'old') {
|
||||
tids = await db.getSortedSetRange(`topics:recent`, 0, meta.config.recentMaxTopics - 1);
|
||||
} else {
|
||||
tids = await db.getSortedSetRevRange(`topics:${params.sort}`, 0, meta.config.recentMaxTopics - 1);
|
||||
const method = params.sort === 'old' ?
|
||||
'getSortedSetRange' :
|
||||
'getSortedSetRevRange';
|
||||
tids = await db[method](sortToSet(params.sort), 0, meta.config.recentMaxTopics - 1);
|
||||
}
|
||||
|
||||
return tids;
|
||||
}
|
||||
|
||||
function sortToSet(sort) {
|
||||
const map = {
|
||||
recent: 'topics:recent',
|
||||
old: 'topics:recent',
|
||||
create: 'topics:tid',
|
||||
posts: 'topics:posts',
|
||||
votes: 'topics:votes',
|
||||
views: 'topics:views',
|
||||
};
|
||||
if (map.hasOwnProperty(sort)) {
|
||||
return map[sort];
|
||||
}
|
||||
return 'topics:recent';
|
||||
}
|
||||
|
||||
async function getTidsWithMostPostsInTerm(term) {
|
||||
const pids = await db.getSortedSetRevRangeByScore('posts:pid', 0, -1, '+inf', Date.now() - Topics.getSinceFromTerm(term));
|
||||
const postObjs = await db.getObjectsFields(pids.map(pid => `post:${pid}`), ['tid']);
|
||||
@@ -93,9 +109,7 @@ module.exports = function (Topics) {
|
||||
|
||||
async function getTagTids(params) {
|
||||
const sets = [
|
||||
params.sort === 'old' ?
|
||||
'topics:recent' :
|
||||
`topics:${params.sort}`,
|
||||
sortToSet(params.sort),
|
||||
...params.tags.map(tag => `tag:${tag}:topics`),
|
||||
];
|
||||
const method = params.sort === 'old' ?
|
||||
@@ -146,11 +160,12 @@ module.exports = function (Topics) {
|
||||
}
|
||||
|
||||
const topicData = await Topics.getTopicsFields(tids, [
|
||||
'tid', 'lastposttime', 'upvotes', 'downvotes', 'postcount', 'pinned',
|
||||
'tid', 'timestamp', 'lastposttime', 'upvotes', 'downvotes', 'postcount', 'pinned',
|
||||
]);
|
||||
const sortMap = {
|
||||
recent: sortRecent,
|
||||
old: sortOld,
|
||||
create: sortCreate,
|
||||
posts: sortPopular,
|
||||
votes: sortVotes,
|
||||
views: sortViews,
|
||||
@@ -178,6 +193,10 @@ module.exports = function (Topics) {
|
||||
return a.lastposttime - b.lastposttime;
|
||||
}
|
||||
|
||||
function sortCreate(a, b) {
|
||||
return b.timestamp - a.timestamp;
|
||||
}
|
||||
|
||||
function sortVotes(a, b) {
|
||||
if (a.votes !== b.votes) {
|
||||
return b.votes - a.votes;
|
||||
|
||||
Reference in New Issue
Block a user