From 2268eb3222fe81681fa6f8ab7ecbb35f03128aa1 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Tue, 1 Oct 2024 09:43:11 +0200 Subject: [PATCH] Chore: do fewer queries --- src/lib/features/project/project-owners-read-model.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/features/project/project-owners-read-model.ts b/src/lib/features/project/project-owners-read-model.ts index c7138cce2746..463cd8648417 100644 --- a/src/lib/features/project/project-owners-read-model.ts +++ b/src/lib/features/project/project-owners-read-model.ts @@ -159,9 +159,10 @@ export class ProjectOwnersReadModel implements IProjectOwnersReadModel { } async getUserProjectOwners(projectId: string): Promise { - const allOwners = await this.getProjectOwnersDictionary(); - return (allOwners[projectId] ?? []).filter( - (owner) => owner.ownerType === 'user', - ) as UserProjectOwner[]; + const ownerRole = await this.db(T.ROLES) + .where({ name: RoleName.OWNER }) + .first(); + const usersDict = await this.getAllProjectUsersByRole(ownerRole.id); + return usersDict[projectId] ?? []; } }