remove redundant joins

This commit is contained in:
Namekuji 2023-08-02 04:07:46 -04:00
parent 91c2aa4715
commit af70257c6d
No known key found for this signature in database
GPG key ID: 1D62332C07FBA532

View file

@ -53,30 +53,16 @@ export default define(meta, paramDef, async (ps, user) => {
throw err; throw err;
}); });
let query = makePaginationQuery( const query = makePaginationQuery(
Notes.createQueryBuilder("note"), Notes.createQueryBuilder("note"),
ps.sinceId, ps.sinceId,
ps.untilId, ps.untilId,
) ).andWhere("note.renoteId = :renoteId", { renoteId: note.id });
.andWhere("note.renoteId = :renoteId", { renoteId: note.id })
.innerJoinAndSelect("note.user", "user");
if (ps.userId) { if (ps.userId) {
query.andWhere("user.id = :userId", { userId: ps.userId }); query.andWhere("note.userId = :userId", { userId: ps.userId });
} }
query
.leftJoinAndSelect("user.avatar", "avatar")
.leftJoinAndSelect("user.banner", "banner")
.leftJoinAndSelect("note.reply", "reply")
.leftJoinAndSelect("note.renote", "renote")
.leftJoinAndSelect("reply.user", "replyUser")
.leftJoinAndSelect("replyUser.avatar", "replyUserAvatar")
.leftJoinAndSelect("replyUser.banner", "replyUserBanner")
.leftJoinAndSelect("renote.user", "renoteUser")
.leftJoinAndSelect("renoteUser.avatar", "renoteUserAvatar")
.leftJoinAndSelect("renoteUser.banner", "renoteUserBanner");
generateVisibilityQuery(query, user); generateVisibilityQuery(query, user);
if (user) generateMutedUserQuery(query, user); if (user) generateMutedUserQuery(query, user);
if (user) generateBlockedUserQuery(query, user); if (user) generateBlockedUserQuery(query, user);