parent
b9c5bbd463
commit
8dd9b51ca5
|
@ -137,27 +137,30 @@ async function fetchRollupVisualizations(
|
|||
let rollupVisualizationsFromSavedSearches = 0;
|
||||
|
||||
visualizations.forEach((visualization: any) => {
|
||||
const {
|
||||
_source: {
|
||||
visualization: {
|
||||
savedSearchRefName,
|
||||
kibanaSavedObjectMeta: { searchSourceJSON },
|
||||
},
|
||||
references = [] as any[],
|
||||
},
|
||||
} = visualization;
|
||||
const references: Array<{ name: string; id: string }> | undefined = get(
|
||||
visualization,
|
||||
'_source.references'
|
||||
);
|
||||
const savedSearchRefName: string | undefined = get(
|
||||
visualization,
|
||||
'_source.visualization.savedSearchRefName'
|
||||
);
|
||||
const searchSourceJSON: string | undefined = get(
|
||||
visualization,
|
||||
'_source.visualization.kibanaSavedObjectMeta.searchSourceJSON'
|
||||
);
|
||||
|
||||
const searchSource = JSON.parse(searchSourceJSON);
|
||||
|
||||
if (savedSearchRefName) {
|
||||
if (savedSearchRefName && references?.length) {
|
||||
// This visualization depends upon a saved search.
|
||||
const savedSearch = references.find((ref: any) => ref.name === savedSearchRefName);
|
||||
if (rollupSavedSearchesToFlagMap[savedSearch.id]) {
|
||||
const savedSearch = references.find(({ name }) => name === savedSearchRefName);
|
||||
if (savedSearch && rollupSavedSearchesToFlagMap[savedSearch.id]) {
|
||||
rollupVisualizations++;
|
||||
rollupVisualizationsFromSavedSearches++;
|
||||
}
|
||||
} else {
|
||||
} else if (searchSourceJSON) {
|
||||
// This visualization depends upon an index pattern.
|
||||
const searchSource = JSON.parse(searchSourceJSON);
|
||||
|
||||
if (rollupIndexPatternToFlagMap[searchSource.index]) {
|
||||
rollupVisualizations++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue