mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: project members not hardcoded (#6658)
This commit is contained in:
parent
ce4a243165
commit
2f7580e6b1
@ -8,9 +8,13 @@ import type {
|
|||||||
} from '../../types';
|
} from '../../types';
|
||||||
import { calculateAverageTimeToProd } from '../feature-toggle/time-to-production/time-to-production';
|
import { calculateAverageTimeToProd } from '../feature-toggle/time-to-production/time-to-production';
|
||||||
import type { IProjectStatsStore } from '../../types/stores/project-stats-store-type';
|
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 { calculateProjectHealth } from '../../domain/project-health/project-health';
|
||||||
import type { IProjectInsightsReadModel } from './project-insights-read-model-type';
|
import type { IProjectInsightsReadModel } from './project-insights-read-model-type';
|
||||||
|
import { subDays } from 'date-fns';
|
||||||
|
|
||||||
export class ProjectInsightsService {
|
export class ProjectInsightsService {
|
||||||
private projectStore: IProjectStore;
|
private projectStore: IProjectStore;
|
||||||
@ -122,33 +126,51 @@ export class ProjectInsightsService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProjectInsights(projectId: string) {
|
private async getProjectMembers(
|
||||||
const result = {
|
projectId: string,
|
||||||
members: {
|
): Promise<ProjectInsightsSchema['members']> {
|
||||||
currentMembers: 20,
|
const dateMinusThirtyDays = subDays(new Date(), 30).toISOString();
|
||||||
change: 3,
|
const [currentMembers, change] = await Promise.all([
|
||||||
},
|
this.projectStore.getMembersCountByProject(projectId),
|
||||||
};
|
this.projectStore.getMembersCountByProjectAfterDate(
|
||||||
|
projectId,
|
||||||
const [stats, featureTypeCounts, health, leadTime, changeRequests] =
|
dateMinusThirtyDays,
|
||||||
await Promise.all([
|
),
|
||||||
this.projectStatsStore.getProjectStats(projectId),
|
]);
|
||||||
this.featureToggleStore.getFeatureTypeCounts({
|
|
||||||
projectId,
|
|
||||||
archived: false,
|
|
||||||
}),
|
|
||||||
this.getHealthInsights(projectId),
|
|
||||||
this.getDoraMetrics(projectId),
|
|
||||||
this.projectInsightsReadModel.getChangeRequests(projectId),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
currentMembers,
|
||||||
|
change,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async getProjectInsights(projectId: string) {
|
||||||
|
const [
|
||||||
stats,
|
stats,
|
||||||
featureTypeCounts,
|
featureTypeCounts,
|
||||||
health,
|
health,
|
||||||
leadTime,
|
leadTime,
|
||||||
changeRequests,
|
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 {
|
||||||
|
stats,
|
||||||
|
featureTypeCounts,
|
||||||
|
health,
|
||||||
|
leadTime,
|
||||||
|
changeRequests,
|
||||||
|
members,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user