Skip to content

Commit

Permalink
feat: project members not hardcoded (#6658)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus committed Mar 21, 2024
1 parent ce4a243 commit 2f7580e
Showing 1 changed file with 41 additions and 19 deletions.
60 changes: 41 additions & 19 deletions src/lib/features/project-insights/project-insights-service.ts
Expand Up @@ -8,9 +8,13 @@ import type {
} from '../../types';
import { calculateAverageTimeToProd } from '../feature-toggle/time-to-production/time-to-production';
import type { IProjectStatsStore } from '../../types/stores/project-stats-store-type';
import type { ProjectDoraMetricsSchema } from '../../openapi';
import type {
ProjectDoraMetricsSchema,
ProjectInsightsSchema,
} from '../../openapi';
import { calculateProjectHealth } from '../../domain/project-health/project-health';
import type { IProjectInsightsReadModel } from './project-insights-read-model-type';
import { subDays } from 'date-fns';

export class ProjectInsightsService {
private projectStore: IProjectStore;
Expand Down Expand Up @@ -122,33 +126,51 @@ export class ProjectInsightsService {
};
}

async getProjectInsights(projectId: string) {
const result = {
members: {
currentMembers: 20,
change: 3,
},
private async getProjectMembers(
projectId: string,
): Promise<ProjectInsightsSchema['members']> {
const dateMinusThirtyDays = subDays(new Date(), 30).toISOString();
const [currentMembers, change] = await Promise.all([
this.projectStore.getMembersCountByProject(projectId),
this.projectStore.getMembersCountByProjectAfterDate(
projectId,
dateMinusThirtyDays,
),
]);

return {
currentMembers,
change,
};
}

const [stats, featureTypeCounts, health, leadTime, changeRequests] =
await Promise.all([
this.projectStatsStore.getProjectStats(projectId),
this.featureToggleStore.getFeatureTypeCounts({
projectId,
archived: false,
}),
this.getHealthInsights(projectId),
this.getDoraMetrics(projectId),
this.projectInsightsReadModel.getChangeRequests(projectId),
]);
async getProjectInsights(projectId: string) {
const [
stats,
featureTypeCounts,
health,
leadTime,
changeRequests,
members,
] = await Promise.all([
this.projectStatsStore.getProjectStats(projectId),
this.featureToggleStore.getFeatureTypeCounts({
projectId,
archived: false,
}),
this.getHealthInsights(projectId),
this.getDoraMetrics(projectId),
this.projectInsightsReadModel.getChangeRequests(projectId),
this.getProjectMembers(projectId),
]);

return {
...result,
stats,
featureTypeCounts,
health,
leadTime,
changeRequests,
members,
};
}
}

0 comments on commit 2f7580e

Please sign in to comment.