refactor(backend): UserEntityService.packMany()の高速化 (#13550)

* refactor(backend): UserEntityService.packMany()の高速化

* 修正
This commit is contained in:
おさむのひと 2024-03-12 14:31:34 +09:00 committed by GitHub
parent 6d9c234cb6
commit 5c1d86b796
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 729 additions and 36 deletions

View file

@ -132,11 +132,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private userEntityService: UserEntityService,
) {
super(meta, paramDef, async (ps, me) => {
const ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId];
const relations = await Promise.all(ids.map(id => this.userEntityService.getRelation(me.id, id)));
return Array.isArray(ps.userId) ? relations : relations[0];
return Array.isArray(ps.userId)
? await this.userEntityService.getRelations(me.id, ps.userId).then(it => [...it.values()])
: await this.userEntityService.getRelation(me.id, ps.userId).then(it => [it]);
});
}
}