summaryrefslogtreecommitdiff
path: root/packages/backend/src/server
diff options
context:
space:
mode:
authorおさむのひと <46447427+samunohito@users.noreply.github.com>2024-03-12 14:31:34 +0900
committerGitHub <noreply@github.com>2024-03-12 14:31:34 +0900
commit5c1d86b796d6ab878bc4f9bd2faf4207998e71cf (patch)
treeedf98d9b2a6b8d1e44a510c718c83308a8572b17 /packages/backend/src/server
parentfix: URL preview popup for local URL appears in the upper left corner (#13555) (diff)
downloadsharkey-5c1d86b796d6ab878bc4f9bd2faf4207998e71cf.tar.gz
sharkey-5c1d86b796d6ab878bc4f9bd2faf4207998e71cf.tar.bz2
sharkey-5c1d86b796d6ab878bc4f9bd2faf4207998e71cf.zip
refactor(backend): UserEntityService.packMany()の高速化 (#13550)
* refactor(backend): UserEntityService.packMany()の高速化 * 修正
Diffstat (limited to 'packages/backend/src/server')
-rw-r--r--packages/backend/src/server/api/endpoints/users/relation.ts8
1 files changed, 3 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/endpoints/users/relation.ts b/packages/backend/src/server/api/endpoints/users/relation.ts
index 6a5b2262fa..1d75437b81 100644
--- a/packages/backend/src/server/api/endpoints/users/relation.ts
+++ b/packages/backend/src/server/api/endpoints/users/relation.ts
@@ -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]);
});
}
}