From e987a50e9fc7bee1b86840cee15a6c86d2d1525d Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 21 Mar 2021 10:41:21 +0900 Subject: [PATCH] perf(server): Improve following/followers API performance Related #6813 --- src/server/api/endpoints/users/followers.ts | 3 ++- src/server/api/endpoints/users/following.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/api/endpoints/users/followers.ts b/src/server/api/endpoints/users/followers.ts index bd4a2739c..fb83d7beb 100644 --- a/src/server/api/endpoints/users/followers.ts +++ b/src/server/api/endpoints/users/followers.ts @@ -76,7 +76,8 @@ export default define(meta, async (ps, me) => { } const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) - .andWhere(`following.followeeId = :userId`, { userId: user.id }); + .andWhere(`following.followeeId = :userId`, { userId: user.id }) + .innerJoinAndSelect('following.follower', 'follower'); const followings = await query .take(ps.limit!) diff --git a/src/server/api/endpoints/users/following.ts b/src/server/api/endpoints/users/following.ts index 9efb8bfc9..d5e8dc1f9 100644 --- a/src/server/api/endpoints/users/following.ts +++ b/src/server/api/endpoints/users/following.ts @@ -76,7 +76,8 @@ export default define(meta, async (ps, me) => { } const query = makePaginationQuery(Followings.createQueryBuilder('following'), ps.sinceId, ps.untilId) - .andWhere(`following.followerId = :userId`, { userId: user.id }); + .andWhere(`following.followerId = :userId`, { userId: user.id }) + .innerJoinAndSelect('following.followee', 'followee'); const followings = await query .take(ps.limit!)