From d1c6da7b643779e3ccde9b4e2bd015132138b550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Fern=C3=A1ndez?= Date: Fri, 15 Dec 2023 13:09:38 +0100 Subject: [PATCH] Explore: Avoid swapping time range when `from` value is after `to` value (#79520) --- public/app/core/utils/explore.test.ts | 4 ++-- public/app/core/utils/explore.ts | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/public/app/core/utils/explore.test.ts b/public/app/core/utils/explore.test.ts index f08d940f559..07a840f7a3e 100644 --- a/public/app/core/utils/explore.test.ts +++ b/public/app/core/utils/explore.test.ts @@ -187,7 +187,7 @@ describe('hasNonEmptyQuery', () => { }); describe('getTimeRange', () => { - describe('should flip from and to when from is after to', () => { + describe('should not flip from and to when from is after to', () => { const rawRange = { from: 'now', to: 'now-6h', @@ -195,7 +195,7 @@ describe('getTimeRange', () => { const range = getTimeRange('utc', rawRange, 0); - expect(range.from.isBefore(range.to)).toBe(true); + expect(range.from.isBefore(range.to)).toBe(false); }); }); diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index e304eac1a7d..7c138740d6b 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -317,10 +317,6 @@ export const getQueryKeys = (queries: DataQuery[]): string[] => { export const getTimeRange = (timeZone: TimeZone, rawRange: RawTimeRange, fiscalYearStartMonth: number): TimeRange => { let range = rangeUtil.convertRawToRange(rawRange, timeZone, fiscalYearStartMonth); - if (range.to.isBefore(range.from)) { - range = rangeUtil.convertRawToRange({ from: range.raw.to, to: range.raw.from }, timeZone, fiscalYearStartMonth); - } - return range; };