Skip to content

Commit

Permalink
feat: return project owners for project
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Oct 1, 2024
1 parent dcb0228 commit f2cfdf6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/features/personal-dashboard/personal-dashboard-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
import type { FeatureEventFormatter } from '../../addons/feature-event-formatter-md';
import { generateImageUrl } from '../../util';
import type { OnboardingStatus } from '../onboarding/onboarding-read-model-type';
import type { PersonalDashboardProjectDetailsSchema } from '../../openapi';

type PersonalProjectDetails = {
latestEvents: {
Expand Down Expand Up @@ -106,7 +107,7 @@ export class PersonalDashboardService {

async getPersonalProjectDetails(
projectId: string,
): Promise<PersonalProjectDetails> {
): Promise<PersonalDashboardProjectDetailsSchema> {
const recentEvents = await this.eventStore.searchEvents(
{ limit: 4, offset: 0 },
[{ field: 'project', operator: 'IS', values: [projectId] }],
Expand All @@ -124,7 +125,16 @@ export class PersonalDashboardService {
createdByImageUrl: generateImageUrl({ email: event.createdBy }),
}));

return { latestEvents: formattedEvents, onboardingStatus };
const owners =
await this.projectOwnersReadModel.getUserProjectOwners(projectId);
// const roles = ..

return {
latestEvents: formattedEvents,
onboardingStatus,
owners,
roles: [],
};
}

async getAdmins(): Promise<MinimalUser[]> {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/features/project/fake-project-owners-read-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ export class FakeProjectOwnersReadModel implements IProjectOwnersReadModel {
async getAllUserProjectOwners(): Promise<UserProjectOwner[]> {
return [];
}

async getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]> {
return [];
}
}
7 changes: 7 additions & 0 deletions src/lib/features/project/project-owners-read-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,11 @@ export class ProjectOwnersReadModel implements IProjectOwnersReadModel {

return ProjectOwnersReadModel.addOwnerData(projects, owners);
}

async getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]> {
const allOwners = await this.getProjectOwnersDictionary();
return (allOwners[projectId] ?? []).filter(
(owner) => owner.ownerType === 'user',
) as UserProjectOwner[];
}
}
2 changes: 2 additions & 0 deletions src/lib/features/project/project-owners-read-model.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export interface IProjectOwnersReadModel {
projects: T[],
): Promise<WithProjectOwners<T>>;

getUserProjectOwners(projectId: string): Promise<UserProjectOwner[]>;

getAllUserProjectOwners(
projects?: Set<string>,
): Promise<UserProjectOwner[]>;
Expand Down

0 comments on commit f2cfdf6

Please sign in to comment.