import { IAggConfigs } from '../../agg_configs' ; import { IMetricAggConfig } from '../metric_agg_type' ; export const parentPipelineAggWriter = ( agg , output , aggConfigs ? ) : void => { const customMetric = agg . getParam ( 'customMetric' ) ; const metricAgg = agg . getParam ( 'metricAgg' ) ; const selectedMetric = customMetric || ( aggConfigs && aggConfigs . getResponseAggById ( metricAgg ) ) ; if ( customMetric && customMetric . type . name !== 'count' ) { output . parentAggs = ( output . parentAggs || [ ] ) . concat ( selectedMetric ) ; } output . params = { buckets_path : selectedMetric . type . name === 'count' ? '_count' : selectedMetric . id , } ; } ;