Skip to content

Commit

Permalink
remove some task manager references
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Aug 12, 2020
1 parent 0ff98f6 commit cab5de4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 56 deletions.
26 changes: 4 additions & 22 deletions x-pack/plugins/reporting/server/lib/store/report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Class Report', () => {
created_by: 'created_by_test_string',
browser_type: 'browser_type_test_string',
max_attempts: 50,
payload: { headers: 'payload_test_field', objectType: 'testOt', layout: {} as any },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
timeout: 30000,
priority: 1,
});
Expand All @@ -30,23 +30,19 @@ describe('Class Report', () => {
jobtype: 'test-report',
max_attempts: 50,
meta: undefined,
payload: { headers: 'payload_test_field', objectType: 'testOt', layout: {} },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
priority: 1,
started_at: undefined,
status: 'pending',
timeout: 30000,
},
});
expect(report.toReportTaskJSON()).toMatchObject({
index: '.reporting-test-index-12345',
jobtype: 'test-report',
});
expect(report.toApiJSON()).toMatchObject({
browser_type: 'browser_type_test_string',
created_by: 'created_by_test_string',
jobtype: 'test-report',
max_attempts: 50,
payload: { headers: 'payload_test_field', objectType: 'testOt', layout: {} },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
priority: 1,
timeout: 30000,
});
Expand All @@ -61,7 +57,7 @@ describe('Class Report', () => {
created_by: 'created_by_test_string',
browser_type: 'browser_type_test_string',
max_attempts: 50,
payload: { headers: 'payload_test_field', objectType: 'testOt', layout: {} as any },
payload: { headers: 'payload_test_field', objectType: 'testOt' },
timeout: 30000,
priority: 1,
});
Expand Down Expand Up @@ -99,13 +95,6 @@ describe('Class Report', () => {
},
}
`);
expect(report.toReportTaskJSON()).toMatchInlineSnapshot(`
Object {
"id": "12342p9o387549o2345",
"index": ".reporting-test-update",
"jobtype": "test-report",
}
`);
expect(report.toApiJSON()).toMatchInlineSnapshot(`
Object {
"attempts": 0,
Expand All @@ -130,11 +119,4 @@ describe('Class Report', () => {
}
`);
});

it('throws error if converted to task JSON before being synced with ES storage', () => {
const report = new Report({});
expect(() => report.toReportTaskJSON()).toThrowErrorMatchingInlineSnapshot(
`"Report object is not synced with ES!"`
);
});
});
34 changes: 0 additions & 34 deletions x-pack/plugins/reporting/server/lib/store/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ interface ReportingDocument {
* The document created by Reporting to store as task parameters for Task
* Manager to reference the report in .reporting
*/
export interface ReportTaskJSON {
id: string;
index: string;
jobtype: string;
}

const puid = new Puid();

export class Report implements Partial<ReportingDocument> {
Expand Down Expand Up @@ -144,22 +138,6 @@ export class Report implements Partial<ReportingDocument> {
};
}

/*
* Task parameters for finding the report in the store, finding its export
* type and getting its run function later
*/
toReportTaskJSON(): ReportTaskJSON {
if (!this._id || !this._index) {
throw new Error(`Report object is not synced with ES!`);
}

return {
id: this._id,
index: this._index,
jobtype: this.jobtype,
};
}

/*
* Data structure for API responses
*/
Expand All @@ -182,16 +160,4 @@ export class Report implements Partial<ReportingDocument> {
completed_at: this.completed_at,
};
}

getUser(): string | null {
return this.created_by || null;
}

getPayload() {
return this.payload;
}

getEncryptedHeaders() {
return this.payload.headers;
}
}

0 comments on commit cab5de4

Please sign in to comment.