import { IMetricAggConfig } from '../metric_agg_type' ; import { METRIC_TYPES } from '../metric_agg_types' ; export const siblingPipelineAggWriter = ( agg , output ) => { const customMetric = agg . getParam ( 'customMetric' ) ; if ( ! customMetric ) return ; const metricAgg = customMetric ; const bucketAgg = agg . getParam ( 'customBucket' ) ; if ( metricAgg . type . name !== METRIC_TYPES . COUNT ) { bucketAgg . subAggs = ( output . subAggs || [ ] ) . concat ( metricAgg ) ; output . params . buckets_path = `${ bucketAgg . id }>${ metricAgg . id }` ; } else { output . params . buckets_path = bucketAgg . id + '>_count' ; } output . parentAggs = ( output . parentAggs || [ ] ) . concat ( bucketAgg ) ; } ;