diff --git a/x-pack/legacy/plugins/ml/public/application/explorer/actions/load_explorer_data.ts b/x-pack/legacy/plugins/ml/public/application/explorer/actions/load_explorer_data.ts index ed73405134224..819db630c0609 100644 --- a/x-pack/legacy/plugins/ml/public/application/explorer/actions/load_explorer_data.ts +++ b/x-pack/legacy/plugins/ml/public/application/explorer/actions/load_explorer_data.ts @@ -12,11 +12,11 @@ import { forkJoin, of, Observable, Subject } from 'rxjs'; import { mergeMap, switchMap, tap } from 'rxjs/operators'; import { anomalyDataChange } from '../explorer_charts/explorer_charts_container_service'; -import { VIEW_BY_JOB_LABEL } from '../explorer_constants'; import { explorerService } from '../explorer_dashboard_service'; import { getDateFormatTz, getSelectionInfluencers, + getSelectionJobIds, getSelectionTimeRange, loadAnnotationsTableData, loadAnomaliesTableData, @@ -114,12 +114,7 @@ function loadExplorerData(config: LoadExplorerDataConfig): Observable d.id); - + const jobIds = getSelectionJobIds(selectedCells, selectedJobs); const timerange = getSelectionTimeRange( selectedCells, swimlaneBucketInterval.asSeconds(), diff --git a/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.d.ts b/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.d.ts index 0ab75b1db2972..c60b2d55d8686 100644 --- a/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.d.ts +++ b/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.d.ts @@ -35,10 +35,15 @@ export declare const getDefaultSwimlaneData: () => SwimlaneData; export declare const getInfluencers: (selectedJobs: any[]) => string[]; +export declare const getSelectionJobIds: ( + selectedCells: AppStateSelectedCells | undefined, + selectedJobs: ExplorerJob[] +) => string[]; + export declare const getSelectionInfluencers: ( selectedCells: AppStateSelectedCells | undefined, fieldName: string -) => any[]; +) => string[]; interface SelectionTimeRange { earliestMs: number; diff --git a/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.js b/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.js index 14d356c0d1c81..4818856b8a8d2 100644 --- a/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.js +++ b/x-pack/legacy/plugins/ml/public/application/explorer/explorer_utils.js @@ -222,6 +222,19 @@ export function getSelectionInfluencers(selectedCells, fieldName) { return []; } +export function getSelectionJobIds(selectedCells, selectedJobs) { + if ( + selectedCells !== undefined && + selectedCells.type !== SWIMLANE_TYPE.OVERALL && + selectedCells.viewByFieldName !== undefined && + selectedCells.viewByFieldName === VIEW_BY_JOB_LABEL + ) { + return selectedCells.lanes; + } + + return selectedJobs.map(d => d.id); +} + export function getSwimlaneBucketInterval(selectedJobs, swimlaneContainerWidth) { // Bucketing interval should be the maximum of the chart related interval (i.e. time range related) // and the max bucket span for the jobs shown in the chart. @@ -587,10 +600,7 @@ export async function loadAnomaliesTableData( tableSeverity, influencersFilterQuery ) { - const jobIds = - selectedCells !== undefined && selectedCells.viewByFieldName === VIEW_BY_JOB_LABEL - ? selectedCells.lanes - : selectedJobs.map(d => d.id); + const jobIds = getSelectionJobIds(selectedCells, selectedJobs); const influencers = getSelectionInfluencers(selectedCells, fieldName); const timeRange = getSelectionTimeRange(selectedCells, interval, bounds);