Skip to content

Commit

Permalink
[ML] fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Mar 23, 2020
1 parent 0e3c9e1 commit cd8c140
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions x-pack/plugins/ml/common/types/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ export interface DataRecognizerConfigResponse {
};
}

export type GeneralJobsOverride = Partial<Omit<Job, 'job_id'>>;
export type JobOverride = Partial<Job>;
export type GeneralJobsOverride = Omit<JobOverride, 'job_id'>;
export type JobSpecificOverride = JobOverride & { job_id: Job['job_id'] };

export type JobOverride = Partial<Job> & { job_id: Job['job_id'] };
export function isGeneralJobOverride(override: JobOverride): override is GeneralJobsOverride {
return override.job_id === undefined;
}

export type GeneralDatafeedsOverride = Partial<Omit<Datafeed, 'job_id'>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
KibanaObjectResponse,
DataRecognizerConfigResponse,
GeneralDatafeedsOverride,
JobSpecificOverride,
isGeneralJobOverride,
} from '../../../common/types/modules';
import { getLatestDataOrBucketTimestamp, prefixDatafeedId } from '../../../common/util/job_utils';
import { mlLog } from '../../client/log';
Expand Down Expand Up @@ -1090,10 +1092,10 @@ export class DataRecognizer {
// separate all the overrides.
// the overrides which don't contain a job id will be applied to all jobs in the module
const generalOverrides: GeneralJobsOverride[] = [];
const jobSpecificOverrides: JobOverride[] = [];
const jobSpecificOverrides: JobSpecificOverride[] = [];

overrides.forEach(override => {
if (override.job_id === undefined) {
if (isGeneralJobOverride(override)) {
generalOverrides.push(override);
} else {
jobSpecificOverrides.push(override);
Expand Down

0 comments on commit cd8c140

Please sign in to comment.