feat: added handling with type empty and key present or not

This commit is contained in:
SagarRajput-7 2025-05-28 18:27:50 +05:30
parent c574fc31d9
commit 71f204520b

View File

@ -22,6 +22,7 @@ import { useQueryBuilder } from 'hooks/queryBuilder/useQueryBuilder';
import { getMetricsOperatorsByAttributeType } from 'lib/newQueryBuilder/getMetricsOperatorsByAttributeType';
import { getOperatorsBySourceAndPanelType } from 'lib/newQueryBuilder/getOperatorsBySourceAndPanelType';
import { findDataTypeOfOperator } from 'lib/query/findDataTypeOfOperator';
import { isEmpty } from 'lodash-es';
import { useCallback, useEffect, useState } from 'react';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
import {
@ -203,6 +204,18 @@ export const useQueryOperations: UseQueryOperations = ({
}
newQuery.spaceAggregation = '';
if (isEmpty(newQuery.aggregateAttribute.type)) {
if (!isEmpty(newQuery.aggregateAttribute.key)) {
newQuery.aggregateOperator = MetricAggregateOperator.AVG;
newQuery.timeAggregation = MetricAggregateOperator.AVG;
newQuery.spaceAggregation = MetricAggregateOperator.AVG;
} else {
newQuery.aggregateOperator = MetricAggregateOperator.COUNT;
newQuery.timeAggregation = MetricAggregateOperator.RATE;
newQuery.spaceAggregation = MetricAggregateOperator.SUM;
}
}
}
handleSetQueryData(index, newQuery);