Skip to content

Commit

Permalink
[ML] Anomaly Explorer: Fix cell selection when view-by is job id. (#5…
Browse files Browse the repository at this point in the history
…5841)

Fixes loading influencers, charts and anomaly table if view-by selection is job ID and cells in the overall swimlanes are selected.

Previously, the check to return the job ids to filter on for the query would return the wrong value for a selection in the overall swimlane. This PR move the wrong and redundant code to a fixed util function getSelectionJobIds().
  • Loading branch information
walterra authored Jan 25, 2020
1 parent a63e8a4 commit 88ba41f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -114,12 +114,7 @@ function loadExplorerData(config: LoadExplorerDataConfig): Observable<Partial<Ex
} = config;

const selectionInfluencers = getSelectionInfluencers(selectedCells, viewBySwimlaneFieldName);

const jobIds =
selectedCells !== undefined && selectedCells.viewByFieldName === VIEW_BY_JOB_LABEL
? selectedCells.lanes
: selectedJobs.map(d => d.id);

const jobIds = getSelectionJobIds(selectedCells, selectedJobs);
const timerange = getSelectionTimeRange(
selectedCells,
swimlaneBucketInterval.asSeconds(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 88ba41f

Please sign in to comment.