import { getBucketSize } from '../../helpers/get_bucket_size' ; import { calculateAggRoot } from './calculate_agg_root' ; import { UI_SETTINGS } from '../../../../../../../data/common' ; import type { TableRequestProcessorsFunction } from './types' ; import { createPositiveRate , filter } from '../series/positive_rate' ; export const positiveRate = ( { req , panel , capabilities , uiSettings , buildSeriesMetaParams } ) => ( next ) => async ( doc ) => { const barTargetUiSettings = await uiSettings . get ( UI_SETTINGS . HISTOGRAM_BAR_TARGET ) ; const { interval } = await buildSeriesMetaParams ( ) ; const { intervalString } = getBucketSize ( req , interval , capabilities , barTargetUiSettings ) ; panel . series . forEach ( ( column ) => { const aggRoot = calculateAggRoot ( doc , column ) ; column . metrics . filter ( filter ) . forEach ( createPositiveRate ( doc , intervalString , aggRoot ) ) ; } ) ; return next ( doc ) ; } ;