Skip to content

Commit

Permalink
Es reader update fix (#597)
Browse files Browse the repository at this point in the history
* refactored update fn to give the proper op with correct dates resolves #593

* removed uneeded code notes
  • Loading branch information
jsnoble authored and kstaken committed Oct 30, 2017
1 parent bdbe05a commit e972d2f
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions lib/readers/elasticsearch_date_range/slicer.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,17 @@ function newSlicer(context, opConfig, job, retryData, logger, client) {
}

function updateJob(opConfig, dates) {
var update = {};

if (!opConfig.start) {
update.start = dates.start;
}

if (!opConfig.end) {
update.end = dates.limit;
}

//this sends actual dates to execution context so that it can keep track of them for recoveries
if (update.hasOwnProperty('start') || update.hasOwnProperty('end')) {
// this sends actual dates to execution context so that it can keep
// track of them for recoveries
if (!opConfig.start || !opConfig.end) {
var operations = JSON.parse(process.env.job).operations;
operations.shift();
var update = {
start: dates.start.format(dateFormat),
end: dates.limit.format(dateFormat)
};
var updatedOpConfig = Object.assign({}, opConfig, update);
updatedOpConfig.start = updatedOpConfig.start.format(dateFormat);
updatedOpConfig.end = updatedOpConfig.end.format(dateFormat);

operations.unshift(updatedOpConfig);
events.emit('slicer:job:update', {update: operations})
}
Expand Down

0 comments on commit e972d2f

Please sign in to comment.