From 499af68f4fcccc4116f98f246797cb90a9fa5801 Mon Sep 17 00:00:00 2001 From: Aditya Hegde Date: Wed, 8 Oct 2025 11:53:25 +0530 Subject: [PATCH] fix: legacy iso time range comparisions in reports --- .../src/features/alerts/alert-preview-data.ts | 1 + .../time-controls/time-range-mappers.ts | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/web-common/src/features/alerts/alert-preview-data.ts b/web-common/src/features/alerts/alert-preview-data.ts index 4de5fcdcbdb..9e82f535a17 100644 --- a/web-common/src/features/alerts/alert-preview-data.ts +++ b/web-common/src/features/alerts/alert-preview-data.ts @@ -87,6 +87,7 @@ function getAlertPreviewQueryRequest( timeControlArgs, exploreSpec, ); + req.limit = "50"; // arbitrary limit to make sure we do not pull too much of data if (!timeControlArgs.selectedTimeRange?.end) return req; diff --git a/web-common/src/features/dashboards/time-controls/time-range-mappers.ts b/web-common/src/features/dashboards/time-controls/time-range-mappers.ts index 0538cf168ad..a4d3c87620e 100644 --- a/web-common/src/features/dashboards/time-controls/time-range-mappers.ts +++ b/web-common/src/features/dashboards/time-controls/time-range-mappers.ts @@ -105,28 +105,36 @@ export function mapSelectedComparisonTimeRangeToV1TimeRange( return undefined; } + let isoDuration = timeRange.isoDuration; + const name = selectedComparisonTimeRange.name; + if ( timeRange.expression && TIME_COMPARISON[selectedComparisonTimeRange.name]?.rillTimeOffset ) { const rt = parseRillTime(timeRange.expression); - return { - expression: - rt.toString() + - " offset " + - TIME_COMPARISON[selectedComparisonTimeRange.name]?.rillTimeOffset, - }; + if (!rt.isOldFormat) { + return { + expression: + rt.toString() + + " offset " + + TIME_COMPARISON[selectedComparisonTimeRange.name]?.rillTimeOffset, + }; + } else { + // Handle old syntax differently until we have the backend parser updated. + isoDuration = timeRange.expression; + } } const comparisonTimeRange: V1TimeRange = {}; - switch (selectedComparisonTimeRange.name) { + switch (name) { default: comparisonTimeRange.isoOffset = selectedComparisonTimeRange.name; - comparisonTimeRange.isoDuration = timeRange.isoDuration; + comparisonTimeRange.isoDuration = isoDuration; break; case TimeComparisonOption.CONTIGUOUS: comparisonTimeRange.isoOffset = comparisonTimeRange.isoDuration = - timeRange.isoDuration; + isoDuration; break; case TimeComparisonOption.CUSTOM: