Skip to content

Commit

Permalink
[ML] Remove excludeGenerated
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jan 25, 2021
1 parent 3a1f788 commit e9ad8f1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { JOB_STATE, DATAFEED_STATE } from '../../../../../common/constants/state
import { parseInterval } from '../../../../../common/util/parse_interval';
import { mlCalendarService } from '../../../services/calendar_service';

export function loadFullJob(jobId, excludeGenerated = false) {
export function loadFullJob(jobId) {
return new Promise((resolve, reject) => {
ml.jobs
.jobs([jobId], excludeGenerated)
.jobs([jobId])
.then((jobs) => {
if (jobs.length) {
resolve(jobs[0]);
Expand Down Expand Up @@ -201,13 +201,15 @@ export async function cloneJob(jobId) {
loadJobForExport(jobId),
loadFullJob(jobId, false),
]);
if (originalJob?.custom_settings?.created_by !== undefined) {
if (cloneableJob !== undefined && originalJob?.custom_settings?.created_by !== undefined) {
// if the job is from a wizards, i.e. contains a created_by property
// use tempJobCloningObjects to temporarily store the job
// cloneableJob.custom_settings.created_by = originalJob?.custom_settings?.created_by;

if (cloneableJob.custom_settings === undefined) {
cloneableJob.custom_settings = originalJob?.custom_settings;
cloneableJob.custom_settings = originalJob.custom_settings;
} else {
cloneableJob.custom_settings.created_by = originalJob.custom_settings.created_by;
}

mlJobService.tempJobCloningObjects.job = cloneableJob;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ export const jobsApiProvider = (httpService: HttpService) => ({
});
},

jobs(jobIds: string[], excludeGenerated?: boolean) {
const body = JSON.stringify({ jobIds, excludeGenerated });
jobs(jobIds: string[]) {
const body = JSON.stringify({ jobIds });
return httpService.http<CombinedJobWithStats[]>({
path: `${basePath()}/jobs/jobs`,
method: 'POST',
Expand Down
12 changes: 3 additions & 9 deletions x-pack/plugins/ml/server/models/job_service/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) {
return jobs;
}

async function createFullJobsList(jobIds: string[] = [], excludeGenerated = false) {
async function createFullJobsList(jobIds: string[] = []) {
const jobs: CombinedJobWithStats[] = [];
const groups: { [jobId: string]: string[] } = {};
const datafeeds: { [id: string]: DatafeedWithStats } = {};
Expand All @@ -303,8 +303,6 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) {

const jobIdsString = jobIds.join();

const datafeedParams = excludeGenerated ? { exclude_generated: excludeGenerated } : undefined;

const [
{ body: jobResults },
{ body: jobStatsResults },
Expand All @@ -313,15 +311,11 @@ export function jobsProvider(client: IScopedClusterClient, mlClient: MlClient) {
calendarResults,
latestBucketTimestampByJob,
] = await Promise.all([
mlClient.getJobs<MlJobsResponse>(
jobIds.length > 0
? { job_id: jobIdsString, exclude_generated: excludeGenerated }
: undefined
),
mlClient.getJobs<MlJobsResponse>(jobIds.length > 0 ? { job_id: jobIdsString } : undefined),
mlClient.getJobStats<MlJobsStatsResponse>(
jobIds.length > 0 ? { job_id: jobIdsString } : undefined
),
mlClient.getDatafeeds<MlDatafeedsResponse>(datafeedParams),
mlClient.getDatafeeds<MlDatafeedsResponse>(),
mlClient.getDatafeedStats<MlDatafeedsStatsResponse>(),
calMngr.getAllCalendars(),
getLatestBucketTimestampByJob(),
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/ml/server/routes/job_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ export function jobServiceRoutes({ router, routeGuard }: RouteInitialization) {
routeGuard.fullLicenseAPIGuard(async ({ client, mlClient, request, response }) => {
try {
const { createFullJobsList } = jobServiceProvider(client, mlClient);
const { jobIds, excludeGenerated } = request.body;
const resp = await createFullJobsList(jobIds, excludeGenerated);
const { jobIds } = request.body;
const resp = await createFullJobsList(jobIds);

return response.ok({
body: resp,
Expand Down

0 comments on commit e9ad8f1

Please sign in to comment.