import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames' ; import { environmentQuery } from '../../../common/utils/environment_query' ; import { getConnectionStats } from '../../lib/connections/get_connection_stats' ; import { getConnectionStatsItemsWithRelativeImpact } from '../../lib/connections/get_connection_stats/get_connection_stats_items_with_relative_impact' ; import { Setup } from '../../lib/helpers/setup_request' ; export async function getServiceDependencies ( { setup , start , end , serviceName , numBuckets , environment , offset , } ) { const statsItems = await getConnectionStats ( { setup , start , end , numBuckets , filter : [ { term : { [ SERVICE_NAME ] : serviceName } } , ... environmentQuery ( environment ) , ] , offset , collapseBy : 'downstream' , } ) ; return getConnectionStatsItemsWithRelativeImpact ( statsItems ) ; }