feat: fixed reduceTo not working

This commit is contained in:
SagarRajput-7 2025-07-15 14:08:45 +05:30
parent 3a623fef8f
commit 6ed78e8a4d
2 changed files with 8 additions and 4 deletions

View File

@ -163,6 +163,7 @@ export function parseAggregations(
export function createAggregation( export function createAggregation(
queryData: any, queryData: any,
panelType?: PANEL_TYPES,
): TraceAggregation[] | LogAggregation[] | MetricAggregation[] { ): TraceAggregation[] | LogAggregation[] | MetricAggregation[] {
if (!queryData) { if (!queryData) {
return []; return [];
@ -170,9 +171,10 @@ export function createAggregation(
const haveReduceTo = const haveReduceTo =
queryData.dataSource === DataSource.METRICS && queryData.dataSource === DataSource.METRICS &&
(queryData.panelType === PANEL_TYPES.TABLE || panelType &&
queryData.panelType === PANEL_TYPES.PIE || (panelType === PANEL_TYPES.TABLE ||
queryData.panelType === PANEL_TYPES.VALUE); panelType === PANEL_TYPES.PIE ||
panelType === PANEL_TYPES.VALUE);
if (queryData.dataSource === DataSource.METRICS) { if (queryData.dataSource === DataSource.METRICS) {
return [ return [
@ -219,7 +221,7 @@ function convertBuilderQueriesToV5(
const baseSpec = createBaseSpec(queryData, requestType, panelType); const baseSpec = createBaseSpec(queryData, requestType, panelType);
let spec: QueryEnvelope['spec']; let spec: QueryEnvelope['spec'];
const aggregations = createAggregation(queryData); const aggregations = createAggregation(queryData, panelType);
switch (signal) { switch (signal) {
case 'traces': case 'traces':

View File

@ -1,6 +1,7 @@
/* eslint-disable sonarjs/cognitive-complexity */ /* eslint-disable sonarjs/cognitive-complexity */
import { ColumnsType, ColumnType } from 'antd/es/table'; import { ColumnsType, ColumnType } from 'antd/es/table';
import { createAggregation } from 'api/v5/queryRange/prepareQueryRangePayloadV5'; import { createAggregation } from 'api/v5/queryRange/prepareQueryRangePayloadV5';
import { PANEL_TYPES } from 'constants/queryBuilder';
import { convertUnit } from 'container/NewWidget/RightContainer/dataFormatCategories'; import { convertUnit } from 'container/NewWidget/RightContainer/dataFormatCategories';
import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types'; import { ThresholdProps } from 'container/NewWidget/RightContainer/Threshold/types';
import { QUERY_TABLE_CONFIG } from 'container/QueryTable/config'; import { QUERY_TABLE_CONFIG } from 'container/QueryTable/config';
@ -191,6 +192,7 @@ export function createColumnsAndDataSource(
(query) => query.queryName === item.queryName, (query) => query.queryName === item.queryName,
) )
: undefined, : undefined,
PANEL_TYPES.TABLE,
)?.length > 1; )?.length > 1;
const column: ColumnType<RowData> = { const column: ColumnType<RowData> = {