Explore: Update time range before running queries (#17349)
This makes sure that refresh/update/run query are parsing a
relative time range to get proper epoch time range before
running queries.
Fixes #17322
(cherry picked from commit e951e71843)
This commit is contained in:
committed by
Andrej Ocenas
parent
6a32c29b92
commit
f26831c8a9
@@ -220,6 +220,7 @@ export interface LoadExploreDataSourcesPayload {
|
||||
|
||||
export interface RunQueriesPayload {
|
||||
exploreId: ExploreId;
|
||||
range: TimeRange;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -559,6 +559,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false): ThunkRe
|
||||
supportsTable,
|
||||
datasourceError,
|
||||
containerWidth,
|
||||
range,
|
||||
} = getState().explore[exploreId];
|
||||
|
||||
if (datasourceError) {
|
||||
@@ -576,7 +577,10 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false): ThunkRe
|
||||
// but we're using the datasource interval limit for now
|
||||
const interval = datasourceInstance.interval;
|
||||
|
||||
dispatch(runQueriesAction({ exploreId }));
|
||||
const timeZone = getTimeZone(getState().user);
|
||||
const updatedRange = getTimeRange(timeZone, range.raw);
|
||||
|
||||
dispatch(runQueriesAction({ exploreId, range: updatedRange }));
|
||||
// Keep table queries first since they need to return quickly
|
||||
const tableQueriesPromise =
|
||||
(ignoreUIState || showingTable) && supportsTable
|
||||
|
||||
@@ -568,8 +568,9 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
||||
})
|
||||
.addMapper({
|
||||
filter: runQueriesAction,
|
||||
mapper: (state): ExploreItemState => {
|
||||
const { range, datasourceInstance, containerWidth } = state;
|
||||
mapper: (state, action): ExploreItemState => {
|
||||
const { range } = action.payload;
|
||||
const { datasourceInstance, containerWidth } = state;
|
||||
let interval = '1s';
|
||||
if (datasourceInstance && datasourceInstance.interval) {
|
||||
interval = datasourceInstance.interval;
|
||||
@@ -577,6 +578,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
||||
const queryIntervals = getIntervals(range, interval, containerWidth);
|
||||
return {
|
||||
...state,
|
||||
range,
|
||||
queryIntervals,
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user