From 12f869a21263b59ec6d201bbd6f9dad50ee44887 Mon Sep 17 00:00:00 2001 From: Idriss Neumann Date: Fri, 24 Nov 2023 15:21:57 +0100 Subject: [PATCH] Issue #16: code review, delete unused code --- .../MetricAggregationsEditor/MetricEditor.tsx | 10 ++-------- .../MetricAggregationsEditor/aggregations.ts | 5 ----- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx index e64be88..b63f319 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx +++ b/src/components/QueryEditor/MetricAggregationsEditor/MetricEditor.tsx @@ -15,10 +15,9 @@ import { segmentStyles } from '../styles'; import { SettingsEditor } from './SettingsEditor'; import { isMetricAggregationWithField, - isMetricAggregationWithInlineScript, isMetricAggregationWithSettings, isPipelineAggregation, - isPipelineAggregationWithMultipleBucketPaths, + isPipelineAggregationWithMultipleBucketPaths } from './aggregations'; import { changeMetricField, changeMetricType } from './state/actions'; import { getStyles } from './styles'; @@ -64,13 +63,8 @@ export const MetricEditor = ({ value }: Props) => { const loadOptions = useCallback(async () => { const remoteFields = await getFields(); - // Metric aggregations that have inline script support don't require a field to be set. - if (isMetricAggregationWithInlineScript(value)) { - return [{ label: 'None' }, ...remoteFields]; - } - return remoteFields; - }, [getFields, value]); + }, [getFields]); const previousMetrics = query.metrics!.slice( 0, diff --git a/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts b/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts index 509c426..24e423b 100644 --- a/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts +++ b/src/components/QueryEditor/MetricAggregationsEditor/aggregations.ts @@ -6,7 +6,6 @@ import { BaseMetricAggregation, MetricAggregationWithField, MetricAggregationWithMissingSupport, - MetricAggregationWithInlineScript, PipelineMetricAggregation, MetricAggregationWithSettings, } from '../../../types'; @@ -62,10 +61,6 @@ export const isMetricAggregationWithMeta = ( metric: BaseMetricAggregation | MetricAggregationWithMeta ): metric is MetricAggregationWithMeta => metricAggregationConfig[metric.type].hasMeta; -export const isMetricAggregationWithInlineScript = ( - metric: BaseMetricAggregation | MetricAggregationWithInlineScript -): metric is MetricAggregationWithInlineScript => metricAggregationConfig[metric.type].supportsInlineScript; - export const METRIC_AGGREGATION_TYPES: MetricAggregationType[] = [ 'count', 'avg',