[backend] We don't need to check for visibility if we already filter for public posts only

This commit is contained in:
Laura Hausmann 2023-11-22 03:40:29 +01:00
parent 6bc42c2a9b
commit eff0f32dc1
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
2 changed files with 4 additions and 9 deletions

View file

@ -88,7 +88,8 @@ export default define(meta, paramDef, async (ps, user) => {
ps.sinceDate,
ps.untilDate,
)
.andWhere("(note.visibility = 'public') AND (note.userHost IS NULL)")
.andWhere("note.visibility = 'public'")
.andWhere("note.userHost IS NULL")
.innerJoinAndSelect("note.user", "user")
.leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner")
@ -103,7 +104,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user);
generateRepliesQuery(query, ps.withReplies, user);
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
@ -133,7 +133,6 @@ export default define(meta, paramDef, async (ps, user) => {
);
}
}
query.andWhere("note.visibility != 'hidden'");
//#endregion
process.nextTick(() => {

View file

@ -88,10 +88,8 @@ export default define(meta, paramDef, async (ps, user) => {
ps.sinceDate,
ps.untilDate,
)
.andWhere(
`(note.userHost = ANY ('{"${m.recommendedInstances.join('","')}"}'))`,
)
.andWhere("(note.visibility = 'public')")
.andWhere(`note.userHost IN (:...instances)`, { instances: m.recommendedInstances })
.andWhere("note.visibility = 'public'")
.innerJoinAndSelect("note.user", "user")
.leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner")
@ -106,7 +104,6 @@ export default define(meta, paramDef, async (ps, user) => {
generateChannelQuery(query, user);
generateRepliesQuery(query, ps.withReplies, user);
generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user);
if (user) generateMutedNoteQuery(query, user);
if (user) generateBlockedUserQuery(query, user);
@ -136,7 +133,6 @@ export default define(meta, paramDef, async (ps, user) => {
);
}
}
query.andWhere("note.visibility != 'hidden'");
//#endregion
process.nextTick(() => {