From 3c2a371edbd1f5c381d74afaac64f5d6413cf170 Mon Sep 17 00:00:00 2001 From: Zion Emond Date: Thu, 22 Jun 2023 10:34:55 -0400 Subject: [PATCH 1/2] YTPOS-65 end job when there are no orders to process to avoid errors --- .../int_yotpo_sfra/cartridge/scripts/job/exportOrders.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js b/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js index 4466968..8ffda88 100644 --- a/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js +++ b/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js @@ -188,6 +188,11 @@ function afterChunk(success) { var ExportOrderModel = require('*/cartridge/models/orderexport/exportOrderModel'); var exportOrderModelInstance = new ExportOrderModel(); + if (empty(latestOrderDateTime)) { + yotpoLogger.logMessage('No orders to process. Ending job to avoid errors'); + 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); From 18f5db07e745cd3cf8a0fbae658fc1713191b836 Mon Sep 17 00:00:00 2001 From: Zion Emond Date: Thu, 22 Jun 2023 14:11:28 -0400 Subject: [PATCH 2/2] YTPOS-65 adjust log message and add comment --- .../int_yotpo_sfra/cartridge/scripts/job/exportOrders.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js b/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js index 8ffda88..09f6846 100644 --- a/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js +++ b/cartridges/int_yotpo_sfra/cartridge/scripts/job/exportOrders.js @@ -189,7 +189,8 @@ function afterChunk(success) { var exportOrderModelInstance = new ExportOrderModel(); if (empty(latestOrderDateTime)) { - yotpoLogger.logMessage('No orders to process. Ending job to avoid errors'); + // exiting job here to prevent the comparison below from blowing up if latestOrderDateTime is undefined + yotpoLogger.logMessage('No orders to process. Exiting job.'); return; }