Skip to content

Commit

Permalink
Merge pull request #4 from YotpoLtd/feature/YTPOS-65_endJobWhenNoOrders
Browse files Browse the repository at this point in the history
YTPOS-65 end job when there are no orders to process to avoid errors
  • Loading branch information
mikefromgrr authored Jun 23, 2023
2 parents 86df59c + 18f5db0 commit 856b00a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ function afterChunk(success) {
var ExportOrderModel = require('*/cartridge/models/orderexport/exportOrderModel');
var exportOrderModelInstance = new ExportOrderModel();

if (empty(latestOrderDateTime)) {
// exiting job here to prevent the comparison below from blowing up if latestOrderDateTime is undefined
yotpoLogger.logMessage('No orders to process. Exiting job.');
return;
}

var isSameTime = originalLastExecutionDateTime.valueOf() === latestOrderDateTime.valueOf();
if (isSameTime) {
yotpoLogger.logMessage('New job execution time is identical to previous value; shifting ahead one minute to prevent endless loop', 'error', logLocation);
Expand Down

0 comments on commit 856b00a

Please sign in to comment.