Skip to content

Commit

Permalink
Chore: do fewer queries
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Oct 1, 2024
1 parent f2cfdf6 commit 2268eb3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib/features/project/project-owners-read-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ export class ProjectOwnersReadModel implements IProjectOwnersReadModel {
}

async getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]> {
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] ?? [];
}
}

0 comments on commit 2268eb3

Please sign in to comment.