Skip to content

Commit 7506c9f

Browse files
[Explore] Update timechart onIntervalChange to execute data table queries (#11035)
* Update timechart onIntervalChange to execute data table queries Signed-off-by: Sean Li <[email protected]> * Changeset file for PR #11035 created/updated * Updating tests to include executeDataTableQuery mock Signed-off-by: Sean Li <[email protected]> --------- Signed-off-by: Sean Li <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent 264a0ea commit 7506c9f

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

changelogs/fragments/11035.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Update timechart onIntervalChange to execute data table queries ([#11035](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/11035))

src/plugins/explore/public/components/chart/explore_logs_chart.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jest.mock('../../services/usage_collector', () => ({
2828
jest.mock('../../application/utils/state_management/actions/query_actions', () => ({
2929
executeQueries: jest.fn(() => ({ type: 'mock/executeQueries' })),
3030
executeHistogramQuery: jest.fn(() => ({ type: 'mock/executeHistogramQuery' })),
31+
executeDataTableQuery: jest.fn(() => ({ type: 'mock/executeDataTableQuery' })),
3132
defaultPrepareQueryString: jest.fn((query) => `${query.language}:${query.query}`),
3233
prepareHistogramCacheKey: jest.fn((query) => `histogram:${query.language}:${query.query}`),
3334
}));
@@ -148,6 +149,7 @@ describe('DiscoverChart', () => {
148149
summaryAgentIsAvailable: false,
149150
queryExecutionButtonStatus: 'REFRESH',
150151
isQueryEditorDirty: false,
152+
hasUserInitiatedQuery: false,
151153
},
152154
results: {},
153155
tab: {
@@ -291,7 +293,7 @@ describe('DiscoverChart', () => {
291293
fireEvent.click(changeIntervalButton);
292294

293295
// Should dispatch setInterval, clearResultsByKey, clearQueryStatusMapByKey, and executeHistogramQuery
294-
expect(dispatchSpy).toHaveBeenCalledTimes(4);
296+
expect(dispatchSpy).toHaveBeenCalledTimes(5);
295297
expect(dispatchSpy).toHaveBeenCalledWith(
296298
expect.objectContaining({ type: 'legacy/setInterval' })
297299
);

src/plugins/explore/public/components/chart/explore_logs_chart.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
executeHistogramQuery,
3333
prepareHistogramCacheKey,
3434
defaultPrepareQueryString,
35+
executeDataTableQuery,
3536
} from '../../application/utils/state_management/actions/query_actions';
3637
import { ResultsSummary } from '../results_summary/results_summary';
3738
import { selectSummaryAgentIsAvailable } from '../../application/utils/state_management/selectors';
@@ -69,19 +70,27 @@ export const ExploreLogsChart = ({
6970
const query = useSelector((state: RootState) => state.query);
7071
const breakdownField = useSelector((state: RootState) => state.queryEditor.breakdownField);
7172
const dispatch = useDispatch();
72-
const cacheKey = prepareHistogramCacheKey(query, !!breakdownField);
73+
const histogramCacheKey = prepareHistogramCacheKey(query, !!breakdownField);
74+
const dataTableCacheKey = defaultPrepareQueryString(query);
7375
const onChangeInterval = (newInterval: string) => {
7476
dispatch(setInterval(newInterval));
75-
dispatch(clearResultsByKey(cacheKey));
76-
dispatch(clearQueryStatusMapByKey(cacheKey));
77+
dispatch(clearResultsByKey(histogramCacheKey));
78+
dispatch(clearQueryStatusMapByKey(histogramCacheKey));
7779
dispatch(
7880
executeHistogramQuery({
7981
services,
80-
cacheKey,
82+
cacheKey: histogramCacheKey,
8183
interval: newInterval,
8284
queryString: defaultPrepareQueryString(query),
8385
})
8486
);
87+
dispatch(
88+
executeDataTableQuery({
89+
services,
90+
cacheKey: dataTableCacheKey,
91+
queryString: dataTableCacheKey,
92+
})
93+
);
8594
};
8695
const timefilterUpdateHandler = useCallback(
8796
(ranges: { from: number; to: number }) => {

0 commit comments

Comments
 (0)