Improve performance of notes/following API

This commit is contained in:
Caramel 2024-11-09 00:32:03 +01:00
parent 6ed38f53f5
commit 03559156b9

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" != \'{}\'');