Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed Aug 13, 2020
1 parent e9a809e commit 4861da3
Showing 1 changed file with 14 additions and 40 deletions.
54 changes: 14 additions & 40 deletions x-pack/plugins/reporting/server/lib/esqueue/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,18 @@ export class Worker extends events.EventEmitter {
kibana_name: this.kibanaName,
};

return this.queue.store
.setReportClaimed(
{
_index: job._index,
_id: job._id,
_seq_no: job._seq_no,
_primary_term: job._primary_term,
},
doc
)
.then((response) => {
this.info(`Job marked as claimed: ${getUpdatedDocPath(response)}`);
const updatedJob = {
...job,
...response,
};
updatedJob._source = {
...job._source,
...doc,
};
return updatedJob;
});
return this.queue.store.setReportClaimed(job, doc).then((response) => {
this.info(`Job marked as claimed: ${getUpdatedDocPath(response)}`);
const updatedJob = {
...job,
...response,
};
updatedJob._source = {
...job._source,
...doc,
};
return updatedJob;
});
}

_failJob(job, output = false) {
Expand All @@ -200,15 +190,7 @@ export class Worker extends events.EventEmitter {
});

return this.queue.store
.setReportFailed(
{
_index: job._index,
_id: job._id,
_seq_no: job._seq_no,
_primary_term: job._primary_term,
},
doc
)
.setReportFailed(job, doc)
.then((response) => {
this.info(`Job marked as failed: ${getUpdatedDocPath(response)}`);
})
Expand Down Expand Up @@ -299,15 +281,7 @@ export class Worker extends events.EventEmitter {
};

return this.queue.store
.setReportCompleted(
{
_index: job._index,
_id: job._id,
_seq_no: job._seq_no,
_primary_term: job._primary_term,
},
doc
)
.setReportCompleted(job, doc)
.then((response) => {
const eventOutput = {
job: formatJobObject(job),
Expand Down

0 comments on commit 4861da3

Please sign in to comment.