Skip to content

Commit

Permalink
[ML] SWIM_LANE_DEFAULT_PAGE_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Jul 1, 2020
1 parent 69c5a44 commit 57e4cae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,8 @@ export const VIEW_BY_JOB_LABEL = i18n.translate('xpack.ml.explorer.jobIdLabel',
* aggregations on influencers values.
*/
export const ANOMALY_SWIM_LANE_HARD_LIMIT = 1000;

/**
* Default page size fot the anomaly swim lane.
*/
export const SWIM_LANE_DEFAULT_PAGE_SIZE = 10;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
SwimlaneData,
ViewBySwimLaneData,
} from '../../explorer_utils';
import { SWIM_LANE_DEFAULT_PAGE_SIZE } from '../../explorer_constants';

export interface ExplorerState {
annotationsData: any[];
Expand Down Expand Up @@ -94,7 +95,7 @@ export function getExplorerDefaultState(): ExplorerState {
viewBySwimlaneDataLoading: false,
viewBySwimlaneFieldName: undefined,
viewBySwimlaneOptions: [],
viewByPerPage: 10,
viewByPerPage: SWIM_LANE_DEFAULT_PAGE_SIZE,
viewByFromPage: 1,
swimlaneLimit: undefined,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export function resultsServiceProvider(mlApiServices) {
influencerFieldValues: {
terms: {
field: 'influencer_field_value',
size: maxResults || 1,
size: !!maxResults ? maxResults : ANOMALY_SWIM_LANE_HARD_LIMIT,
order: {
maxAnomalyScore: 'desc',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import { MlStartDependencies } from '../../plugin';
import {
ANOMALY_SWIM_LANE_HARD_LIMIT,
SWIM_LANE_DEFAULT_PAGE_SIZE,
SWIMLANE_TYPE,
SwimlaneType,
} from '../../application/explorer/explorer_constants';
Expand All @@ -53,8 +54,6 @@ function getJobsObservable(
);
}

export const EMBEDDABLE_DEFAULT_PER_PAGE = 10;

export function useSwimlaneInputResolver(
embeddableInput: Observable<AnomalySwimlaneEmbeddableInput>,
onInputChange: (output: Partial<AnomalySwimlaneEmbeddableOutput>) => void,
Expand Down Expand Up @@ -102,7 +101,7 @@ export function useSwimlaneInputResolver(
startWith(undefined),
// no need to emit when the initial value has been set
distinctUntilChanged(
(prev, curr) => prev === undefined && curr === EMBEDDABLE_DEFAULT_PER_PAGE
(prev, curr) => prev === undefined && curr === SWIM_LANE_DEFAULT_PAGE_SIZE
)
),
refresh.pipe(startWith(null)),
Expand Down Expand Up @@ -154,7 +153,7 @@ export function useSwimlaneInputResolver(
if (overallSwimlaneData && swimlaneTypeInput === SWIMLANE_TYPE.VIEW_BY) {
if (perPageFromState === undefined) {
// set initial pagination from the input or default one
setPerPage(perPageInput ?? EMBEDDABLE_DEFAULT_PER_PAGE);
setPerPage(perPageInput ?? SWIM_LANE_DEFAULT_PAGE_SIZE);
}

if (viewMode === ViewMode.EDIT && perPageFromState !== perPageInput) {
Expand All @@ -171,7 +170,7 @@ export function useSwimlaneInputResolver(
isViewBySwimLaneData(swimlaneData)
? swimlaneData.cardinality
: ANOMALY_SWIM_LANE_HARD_LIMIT,
perPageFromState ?? perPageInput ?? EMBEDDABLE_DEFAULT_PER_PAGE,
perPageFromState ?? perPageInput ?? SWIM_LANE_DEFAULT_PAGE_SIZE,
fromPageInput,
swimlaneContainerWidth,
appliedFilters
Expand Down Expand Up @@ -224,7 +223,7 @@ export function useSwimlaneInputResolver(
return [
swimlaneType,
swimlaneData,
perPage ?? EMBEDDABLE_DEFAULT_PER_PAGE,
perPage ?? SWIM_LANE_DEFAULT_PAGE_SIZE,
setPerPage,
timeBuckets,
isLoading,
Expand Down

0 comments on commit 57e4cae

Please sign in to comment.