[ML] Fixing job deletion slow refresh delay (#30371)

This commit is contained in:
James Gowdy 2019-02-08 10:21:24 +00:00 committed by GitHub
parent 7ae1b4f44d
commit 59cddd706d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 9 deletions

View file

@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
export const DEFAULT_REFRESH_INTERVAL_MS = 30000;
export const MINIMUM_REFRESH_INTERVAL_MS = 5000;
export const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000;

View file

@ -12,14 +12,14 @@ export const DATAFEED_STATE = {
STARTING: 'starting',
STOPPED: 'stopped',
STOPPING: 'stopping',
DELETED: 'deleted'
DELETED: 'deleted',
};
export const FORECAST_REQUEST_STATE = {
FAILED: 'failed',
FINISHED: 'finished',
SCHEDULED: 'scheduled',
STARTED: 'started'
STARTED: 'started',
};
export const JOB_STATE = {
@ -27,5 +27,6 @@ export const JOB_STATE = {
CLOSING: 'closing',
FAILED: 'failed',
OPENED: 'opened',
OPENING: 'opening'
OPENING: 'opening',
DELETED: 'deleted',
};

View file

@ -19,6 +19,7 @@ import {
} from '@elastic/eui';
import { deleteJobs } from '../utils';
import { DELETING_JOBS_REFRESH_INTERVAL_MS } from '../../../../../common/constants/jobs_list';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
export const DeleteJobModal = injectI18n(class extends Component {
@ -70,9 +71,9 @@ export const DeleteJobModal = injectI18n(class extends Component {
deleteJobs(this.state.jobs);
setTimeout(() => {
this.closeModal();
this.refreshJobs();
}, 500);
this.closeModal();
}, DELETING_JOBS_REFRESH_INTERVAL_MS);
}
setEL = (el) => {

View file

@ -24,6 +24,12 @@ import { UpgradeWarning } from '../../../../components/upgrade';
import { RefreshJobsListButton } from '../refresh_jobs_list_button';
import { isEqual } from 'lodash';
import {
DEFAULT_REFRESH_INTERVAL_MS,
MINIMUM_REFRESH_INTERVAL_MS,
DELETING_JOBS_REFRESH_INTERVAL_MS,
} from '../../../../../common/constants/jobs_list';
import React, {
Component
} from 'react';
@ -34,9 +40,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
const DEFAULT_REFRESH_INTERVAL_MS = 30000;
const MINIMUM_REFRESH_INTERVAL_MS = 5000;
const DELETING_JOBS_REFRESH_INTERVAL_MS = 2000;
let jobsRefreshInterval = null;
let deletingJobsRefreshTimeout = null;

View file

@ -179,7 +179,7 @@ export function deleteJobs(jobs, finish = () => {}) {
const jobIds = jobs.map(j => j.id);
mlJobService.deleteJobs(jobIds)
.then((resp) => {
showResults(resp, DATAFEED_STATE.DELETED);
showResults(resp, JOB_STATE.DELETED);
finish();
})
.catch((error) => {