Skip to content

Commit

Permalink
[ML] Fix types.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Dec 14, 2020
1 parent 1de3ff4 commit 169c4c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/transform/common/types/pivot_group_by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,23 @@ export type GenericAgg = object;
export interface TermsAgg {
terms: {
field: EsFieldName;
missing_bucket?: boolean;
};
}

export interface HistogramAgg {
histogram: {
field: EsFieldName;
interval: string;
missing_bucket?: boolean;
};
}

export interface DateHistogramAgg {
date_histogram: {
field: EsFieldName;
calendar_interval: string;
missing_bucket?: boolean;
};
}

Expand Down
8 changes: 6 additions & 2 deletions x-pack/plugins/transform/public/app/common/pivot_group_by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ interface GroupByConfigBase {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS;
aggName: AggName;
dropDownName: string;
field: EsFieldName;
missing_bucket?: boolean;
}

// Don't allow an interval of '0', but allow a float interval of '0.1' with a leading zero.
Expand All @@ -52,16 +50,22 @@ export const dateHistogramIntervalFormatRegex = /^[1-9][0-9]*(ms|s|m|h|d|w|M|q|y

interface GroupByDateHistogram extends GroupByConfigBase {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.DATE_HISTOGRAM;
field: EsFieldName;
calendar_interval: string;
missing_bucket?: boolean;
}

interface GroupByHistogram extends GroupByConfigBase {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.HISTOGRAM;
field: EsFieldName;
interval: string;
missing_bucket?: boolean;
}

interface GroupByTerms extends GroupByConfigBase {
agg: PIVOT_SUPPORTED_GROUP_BY_AGGS.TERMS;
field: EsFieldName;
missing_bucket?: boolean;
}

export type GroupByConfigWithInterval = GroupByDateHistogram | GroupByHistogram;
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/transform/public/app/common/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
isGroupByDateHistogram,
isGroupByHistogram,
isGroupByTerms,
GroupByConfigWithUiSupport,
PivotGroupByConfig,
} from '../common';

Expand Down Expand Up @@ -71,7 +72,9 @@ export function isDefaultQuery(query: PivotQuery): boolean {
return isSimpleQuery(query) && query.query_string.query === '*';
}

export const getMissingBucketConfig = (g: PivotGroupByConfig): { missing_bucket?: boolean } => {
export const getMissingBucketConfig = (
g: GroupByConfigWithUiSupport
): { missing_bucket?: boolean } => {
return g.missing_bucket !== undefined ? { missing_bucket: g.missing_bucket } : {};
};

Expand Down

0 comments on commit 169c4c1

Please sign in to comment.