Skip to content

Commit

Permalink
fix warning status handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Apr 14, 2020
1 parent 7852569 commit 978f951
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
13 changes: 8 additions & 5 deletions x-pack/legacy/plugins/reporting/server/lib/esqueue/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,15 @@ export class Worker extends events.EventEmitter {
const completedTime = moment().toISOString();
const docOutput = this._formatOutput(output);

const status =
output && output.warnings
? constants.JOB_STATUS_WARNINGS
: constants.JOB_STATUS_COMPLETED;
let status;
if (output && output.warnings && output.warnings.length > 0) {
status = constants.JOB_STATUS_WARNINGS;
} else {
status = constants.JOB_STATUS_COMPLETED;
}

const doc = {
status,
status: status,
completed_at: completedTime,
output: docOutput,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import contentDisposition from 'content-disposition';
import * as _ from 'lodash';
import { CSV_JOB_TYPE } from '../../../common/constants';
import { ExportTypeDefinition, ExportTypesRegistry, JobDocOutput, JobSource } from '../../../types';
import { statuses } from '../../lib/esqueue/constants/statuses';

interface ICustomHeaders {
[x: string]: any;
Expand Down Expand Up @@ -99,11 +100,11 @@ export function getDocumentPayloadFactory(exportTypesRegistry: ExportTypesRegist
const { status, jobtype: jobType, payload: { title } = { title: '' } } = doc._source;
const { output } = doc._source;

if (status === 'completed') {
if (status === statuses.JOB_STATUS_COMPLETED || status === statuses.JOB_STATUS_WARNINGS) {
return getCompleted(output, jobType, title);
}

if (status === 'failed') {
if (status === statuses.JOB_STATUS_FAILED) {
return getFailure(output);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = { record: ListingJob } & ListingProps;
export const ReportDownloadButton: FunctionComponent<Props> = (props: Props) => {
const { record, apiClient, intl } = props;

if (record.status !== JobStatuses.COMPLETED) {
if (!([JobStatuses.COMPLETED, JobStatuses.WARNINGS] as string[]).includes(record.status)) {
return null;
}

Expand Down
12 changes: 11 additions & 1 deletion x-pack/plugins/reporting/public/components/report_listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ const jobStatusLabelsMap = new Map<JobStatuses, string>([
defaultMessage: 'Completed',
}),
],
[
JobStatuses.WARNINGS,
i18n.translate('xpack.reporting.jobStatuses.warningText', {
defaultMessage: 'Completed with warnings',
}),
],
[
JobStatuses.FAILED,
i18n.translate('xpack.reporting.jobStatuses.failedText', {
Expand Down Expand Up @@ -410,7 +416,11 @@ class ReportListingUi extends Component<Props, State> {
statusTimestamp = this.formatDate(record.started_at);
} else if (
record.completed_at &&
[JobStatuses.COMPLETED, JobStatuses.FAILED, JobStatuses.WARNINGS].includes(status)
([
JobStatuses.COMPLETED,
JobStatuses.FAILED,
JobStatuses.WARNINGS,
] as string[]).includes(status)
) {
statusTimestamp = this.formatDate(record.completed_at);
}
Expand Down

0 comments on commit 978f951

Please sign in to comment.