From 22d5945785c914e2d8ec87121311508a1d94e932 Mon Sep 17 00:00:00 2001 From: Kerry Gallagher <471693+Kerry350@users.noreply.github.com> Date: Thu, 24 Jun 2021 17:40:02 +0100 Subject: [PATCH] Remove function to avoid extra any --- .../infra/common/alerting/logs/log_threshold/types.ts | 7 +------ .../alerting/log_threshold/log_threshold_chart_preview.ts | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts b/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts index 41e4b58b16484..6da0bb58e4e85 100644 --- a/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts +++ b/x-pack/plugins/infra/common/alerting/logs/log_threshold/types.ts @@ -311,12 +311,7 @@ export const OptimizedGroupedSearchQueryResponseRT = rt.intersection([ aggregations: rt.type({ groups: rt.intersection([ rt.type({ - buckets: rt.array( - rt.intersection([ - bucketFieldsRT, - ChartPreviewBucketsRT, - ]) - ), + buckets: rt.array(rt.intersection([bucketFieldsRT, ChartPreviewBucketsRT])), }), afterKeyRT, ]), diff --git a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts index d162200ac8de7..7bf2cb5ea3394 100644 --- a/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts +++ b/x-pack/plugins/infra/server/lib/alerting/log_threshold/log_threshold_chart_preview.ts @@ -98,10 +98,9 @@ const addHistogramAggregationToQuery = ( }; if (isGrouped) { - const isOptimizedQuery = (groupedQuery: any) => - !groupedQuery.body.aggregations.groups.aggregations?.filtered_results ? true : false; + const isOptimizedQuery = !query.body.aggregations.groups.aggregations?.filtered_results; - if (isOptimizedQuery(query)) { + if (isOptimizedQuery) { query.body.aggregations.groups.aggregations = { ...query.body.aggregations.groups.aggregations, ...histogramAggregation,