merge: Improve performance of notes/following API (!743)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/743

Approved-by: Hazelnoot <acomputerdog@gmail.com>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
Hazelnoot 2024-11-09 10:54:18 +00:00
commit cd2e597223
1 changed files with 9 additions and 9 deletions

View File

@ -103,6 +103,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
sub.andWhere('latest.is_quote = false'); sub.andWhere('latest.is_quote = false');
} }
// Select the appropriate collection of users
if (ps.list === 'followers') {
addFollower(sub);
} else if (ps.list === 'following') {
addFollowee(sub);
} else {
addMutual(sub);
}
return sub; return sub;
}, },
'latest', 'latest',
@ -118,15 +127,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
.leftJoinAndSelect('note.channel', 'channel') .leftJoinAndSelect('note.channel', 'channel')
; ;
// Select the appropriate collection of users
if (ps.list === 'followers') {
addFollower(query);
} else if (ps.list === 'following') {
addFollowee(query);
} else {
addMutual(query);
}
// Limit to files, if requested // Limit to files, if requested
if (ps.filesOnly) { if (ps.filesOnly) {
query.andWhere('note."fileIds" != \'{}\''); query.andWhere('note."fileIds" != \'{}\'');