Skip to content

Commit

Permalink
[ML] use MlJobAggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed May 13, 2020
1 parent 55e0aea commit 404bba2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions x-pack/plugins/ml/common/constants/aggregation_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

export type MlJobAggregation = keyof Record<ML_JOB_AGGREGATION, string>;

export enum ML_JOB_AGGREGATION {
// count
COUNT = 'count',
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/ml/common/util/job_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { CombinedJob, CustomSettings, Datafeed, JobId, Job } from '../types/anom
import { EntityField } from './anomaly_utils';
import { MlServerLimits } from '../types/ml_server_info';
import { JobValidationMessage, JobValidationMessageId } from '../constants/messages';
import { MlJobAggregation } from '../constants/aggregation_types';

export interface ValidationResults {
valid: boolean;
Expand Down Expand Up @@ -208,7 +209,7 @@ export function isJobVersionGte(job: CombinedJob, version: string): boolean {
// for querying metric data. Returns null if there is no suitable ES aggregation.
// Note that the 'function' field in a record contains what the user entered e.g. 'high_count',
// whereas the 'function_description' field holds an ML-built display hint for function e.g. 'count'.
export function mlFunctionToESAggregation(functionName: string): string | null {
export function mlFunctionToESAggregation(functionName: MlJobAggregation | string): string | null {
if (
functionName === 'mean' ||
functionName === 'high_mean' ||
Expand Down

0 comments on commit 404bba2

Please sign in to comment.