Skip to content

Commit

Permalink
[ML] Fix Index data visualizer sometimes shows wrong doc count for sa…
Browse files Browse the repository at this point in the history
…ved searches (elastic#106007)

* [ML] Fix flaky saved search

* [ML] Re-enable tests

* [ML] Make data viz the only tests for flaky test suite runner

* [ML] Make ML only

* [ML] Remove describe.only

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
qn895 and kibanamachine committed Jul 19, 2021
1 parent 04bd12b commit 0a4a4dd
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,16 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
const parsedQueryString = parse(prevSearchString, { sort: false });

const getIndexPattern = async () => {
if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}

if (typeof parsedQueryString?.savedSearchId === 'string') {
const savedSearchId = parsedQueryString.savedSearchId;
try {
const savedSearch = await savedObjectsClient.get('search', savedSearchId);
const indexPatternId = savedSearch.references.find((ref) => ref.type === 'index-pattern')
?.id;
if (indexPatternId !== undefined) {
if (indexPatternId !== undefined && savedSearch) {
try {
const indexPattern = await indexPatterns.get(indexPatternId);
setCurrentSavedSearch(savedSearch);
setCurrentIndexPattern(indexPattern);
} catch (e) {
toasts.addError(e, {
Expand All @@ -88,7 +84,6 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}
setCurrentSavedSearch(savedSearch);
} catch (e) {
toasts.addError(e, {
title: i18n.translate('xpack.dataVisualizer.index.savedSearchErrorMessage', {
Expand All @@ -98,6 +93,11 @@ export const DataVisualizerUrlStateContextProvider: FC<DataVisualizerUrlStateCon
});
}
}

if (typeof parsedQueryString?.index === 'string') {
const indexPattern = await indexPatterns.get(parsedQueryString.index);
setCurrentIndexPattern(indexPattern);
}
};
getIndexPattern();
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down

0 comments on commit 0a4a4dd

Please sign in to comment.