mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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';
 | 
			
		||||
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;
 | 
			
		||||
@ -122,16 +126,33 @@ 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,
 | 
			
		||||
            ),
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        const [stats, featureTypeCounts, health, leadTime, changeRequests] =
 | 
			
		||||
            await Promise.all([
 | 
			
		||||
        return {
 | 
			
		||||
            currentMembers,
 | 
			
		||||
            change,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async getProjectInsights(projectId: string) {
 | 
			
		||||
        const [
 | 
			
		||||
            stats,
 | 
			
		||||
            featureTypeCounts,
 | 
			
		||||
            health,
 | 
			
		||||
            leadTime,
 | 
			
		||||
            changeRequests,
 | 
			
		||||
            members,
 | 
			
		||||
        ] = await Promise.all([
 | 
			
		||||
            this.projectStatsStore.getProjectStats(projectId),
 | 
			
		||||
            this.featureToggleStore.getFeatureTypeCounts({
 | 
			
		||||
                projectId,
 | 
			
		||||
@ -140,15 +161,16 @@ export class ProjectInsightsService {
 | 
			
		||||
            this.getHealthInsights(projectId),
 | 
			
		||||
            this.getDoraMetrics(projectId),
 | 
			
		||||
            this.projectInsightsReadModel.getChangeRequests(projectId),
 | 
			
		||||
            this.getProjectMembers(projectId),
 | 
			
		||||
        ]);
 | 
			
		||||
 | 
			
		||||
        return {
 | 
			
		||||
            ...result,
 | 
			
		||||
            stats,
 | 
			
		||||
            featureTypeCounts,
 | 
			
		||||
            health,
 | 
			
		||||
            leadTime,
 | 
			
		||||
            changeRequests,
 | 
			
		||||
            members,
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user