summaryrefslogtreecommitdiff
path: root/packages/backend/src
diff options
context:
space:
mode:
authorsyuilo <4439005+syuilo@users.noreply.github.com>2024-05-10 21:33:20 +0900
committerGitHub <noreply@github.com>2024-05-10 21:33:20 +0900
commit6046ba1841c557f2a7e869889356b9cb775e9aba (patch)
treedb13eb358ae13f500e35b9720f7044189d0a001b /packages/backend/src
parentMerge branch 'develop' into release/2024.5.0 (diff)
parentfix(backend): UserEntityService.getRelationsの取得処理を軽量化 (#13811) (diff)
downloadmisskey-6046ba1841c557f2a7e869889356b9cb775e9aba.tar.gz
misskey-6046ba1841c557f2a7e869889356b9cb775e9aba.tar.bz2
misskey-6046ba1841c557f2a7e869889356b9cb775e9aba.zip
Merge pull request #13816 from misskey-dev/develop
developにマージされた分の追いつき用
Diffstat (limited to 'packages/backend/src')
-rw-r--r--packages/backend/src/core/entities/UserEntityService.ts58
1 files changed, 39 insertions, 19 deletions
diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts
index df2b27d709..b80a1ec206 100644
--- a/packages/backend/src/core/entities/UserEntityService.ts
+++ b/packages/backend/src/core/entities/UserEntityService.ts
@@ -249,20 +249,41 @@ export class UserEntityService implements OnModuleInit {
] = await Promise.all([
this.followingsRepository.findBy({ followerId: me })
.then(f => new Map(f.map(it => [it.followeeId, it]))),
- this.followingsRepository.findBy({ followeeId: me })
- .then(it => it.map(it => it.followerId)),
- this.followRequestsRepository.findBy({ followerId: me })
- .then(it => it.map(it => it.followeeId)),
- this.followRequestsRepository.findBy({ followeeId: me })
- .then(it => it.map(it => it.followerId)),
- this.blockingsRepository.findBy({ blockerId: me })
- .then(it => it.map(it => it.blockeeId)),
- this.blockingsRepository.findBy({ blockeeId: me })
- .then(it => it.map(it => it.blockerId)),
- this.mutingsRepository.findBy({ muterId: me })
- .then(it => it.map(it => it.muteeId)),
- this.renoteMutingsRepository.findBy({ muterId: me })
- .then(it => it.map(it => it.muteeId)),
+ this.followingsRepository.createQueryBuilder('f')
+ .select('f.followerId')
+ .where('f.followeeId = :me', { me })
+ .getRawMany<{ f_followerId: string }>()
+ .then(it => it.map(it => it.f_followerId)),
+ this.followRequestsRepository.createQueryBuilder('f')
+ .select('f.followeeId')
+ .where('f.followerId = :me', { me })
+ .getRawMany<{ f_followeeId: string }>()
+ .then(it => it.map(it => it.f_followeeId)),
+ this.followRequestsRepository.createQueryBuilder('f')
+ .select('f.followerId')
+ .where('f.followeeId = :me', { me })
+ .getRawMany<{ f_followerId: string }>()
+ .then(it => it.map(it => it.f_followerId)),
+ this.blockingsRepository.createQueryBuilder('b')
+ .select('b.blockeeId')
+ .where('b.blockerId = :me', { me })
+ .getRawMany<{ b_blockeeId: string }>()
+ .then(it => it.map(it => it.b_blockeeId)),
+ this.blockingsRepository.createQueryBuilder('b')
+ .select('b.blockerId')
+ .where('b.blockeeId = :me', { me })
+ .getRawMany<{ b_blockerId: string }>()
+ .then(it => it.map(it => it.b_blockerId)),
+ this.mutingsRepository.createQueryBuilder('m')
+ .select('m.muteeId')
+ .where('m.muterId = :me', { me })
+ .getRawMany<{ m_muteeId: string }>()
+ .then(it => it.map(it => it.m_muteeId)),
+ this.renoteMutingsRepository.createQueryBuilder('m')
+ .select('m.muteeId')
+ .where('m.muterId = :me', { me })
+ .getRawMany<{ m_muteeId: string }>()
+ .then(it => it.map(it => it.m_muteeId)),
]);
return new Map(
@@ -637,18 +658,17 @@ export class UserEntityService implements OnModuleInit {
}
const _userIds = _users.map(u => u.id);
- // -- 特に前提条件のない値群を取得
-
- const profilesMap = await this.userProfilesRepository.findBy({ userId: In(_userIds) })
- .then(profiles => new Map(profiles.map(p => [p.userId, p])));
-
// -- 実行者の有無や指定スキーマの種別によって要否が異なる値群を取得
+ let profilesMap: Map<MiUser['id'], MiUserProfile> = new Map();
let userRelations: Map<MiUser['id'], UserRelation> = new Map();
let userMemos: Map<MiUser['id'], string | null> = new Map();
let pinNotes: Map<MiUser['id'], MiUserNotePining[]> = new Map();
if (options?.schema !== 'UserLite') {
+ profilesMap = await this.userProfilesRepository.findBy({ userId: In(_userIds) })
+ .then(profiles => new Map(profiles.map(p => [p.userId, p])));
+
const meId = me ? me.id : null;
if (meId) {
userMemos = await this.userMemosRepository.findBy({ userId: meId })