import { getSeverity } from '../../../../common/anomaly_detection' ; import { getServiceHealthStatus } from '../../../../common/service_health_status' ; import { getServiceAnomalies } from '../../../routes/service_map/get_service_anomalies' ; import { ServicesItemsSetup } from './get_services_items' ; interface AggregationParams { environment : string ; setup : ServicesItemsSetup ; searchAggregatedTransactions : boolean ; start : number ; end : number ; } export const getHealthStatuses = async ( { environment , setup , start , end , } ) => { if ( ! setup . ml ) { return [ ] ; } const anomalies = await getServiceAnomalies ( { setup , environment , start , end , } ) ; return anomalies . serviceAnomalies . map ( ( anomalyStats ) => { const severity = getSeverity ( anomalyStats . anomalyScore ) ; const healthStatus = getServiceHealthStatus ( { severity } ) ; return { serviceName : anomalyStats . serviceName , healthStatus , } ; } ) ; } ;