From 82b1887bfe245b45be5e87f6e2ea31847fcaa1ba Mon Sep 17 00:00:00 2001 From: Chris Raible Date: Wed, 28 Aug 2024 22:21:27 -0700 Subject: [PATCH] Cleaned up deliverytime calculation logic --- ghost/email-service/lib/BatchSendingService.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ghost/email-service/lib/BatchSendingService.js b/ghost/email-service/lib/BatchSendingService.js index ad65785625..c2c8618776 100644 --- a/ghost/email-service/lib/BatchSendingService.js +++ b/ghost/email-service/lib/BatchSendingService.js @@ -380,7 +380,8 @@ class BatchSendingService { // Calculate the target delivery time for the batch const timeRemaining = deadline.getTime() - lastDeliveryTime.getTime(); const targetDeliveryDelay = Math.abs(timeRemaining / (queue.length + 1)); - const targetDeliveryTime = new Date(Math.min(lastDeliveryTime.getTime() + targetDeliveryDelay, deadline.getTime())); + const calculatedDeliveryTime = lastDeliveryTime.getTime() + targetDeliveryDelay; + const targetDeliveryTime = new Date(Math.min(calculatedDeliveryTime, deadline.getTime())); batchData.deliveryTime = targetDeliveryTime; lastDeliveryTime = targetDeliveryTime; }