We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit da417bf3 authored by attilak's avatar attilak

Add shouldSkipProcessingNotification()

To check if notification processing should be skipped
Add log if notification should be skipped
parent 37f8a7d5
...@@ -331,24 +331,16 @@ class Cron ...@@ -331,24 +331,16 @@ class Cron
} }
} }
public function execute() /**
* @param $notification
* @return bool
*/
private function shouldSkipProcessingNotification($notification)
{ {
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$renderer = Phrase::getRenderer();
if ($renderer instanceof Placeholder) {
$this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
}
$this->_order = null;
$notifications = $this->_notificationFactory->create();
$notifications->notificationsToProcessFilter();
// OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed // OFFER_CLOSED notifications needs to be at least 10 minutes old to be processed
$offerClosedMinDate = new \DateTime(); $offerClosedMinDate = new \DateTime();
$offerClosedMinDate->modify('-10 minutes'); $offerClosedMinDate->modify('-10 minutes');
foreach ($notifications as $notification) {
// Remove OFFER_CLOSED notifications arrived in the last 10 minutes from the list to process to ensure it // Remove OFFER_CLOSED notifications arrived in the last 10 minutes from the list to process to ensure it
// won't close any order which has an AUTHORISED notification arrived a bit later than the OFFER_CLOSED one. // won't close any order which has an AUTHORISED notification arrived a bit later than the OFFER_CLOSED one.
$createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']); $createdAt = \DateTime::createFromFormat('Y-m-d H:i:s', $notification['created_at']);
...@@ -360,11 +352,36 @@ class Cron ...@@ -360,11 +352,36 @@ class Cron
sprintf('OFFER_CLOSED notification %s skipped! Wait %s minute(s) before processing.', sprintf('OFFER_CLOSED notification %s skipped! Wait %s minute(s) before processing.',
$notification->getEntityId(), $minutesUntilProcessing) $notification->getEntityId(), $minutesUntilProcessing)
); );
return true;
}
return false;
}
public function execute()
{
// needed for Magento < 2.2.0 https://github.com/magento/magento2/pull/8413
$renderer = Phrase::getRenderer();
if ($renderer instanceof Placeholder) {
$this->_areaList->getArea(Area::AREA_CRONTAB)->load(Area::PART_TRANSLATE);
}
$this->_order = null;
$notifications = $this->_notificationFactory->create();
$notifications->notificationsToProcessFilter();
// Loop thorugh notifications to set processing to true if notifiaction should not be skipped
foreach ($notifications as $notification) {
// Check if notification should be processed or not
if ($this->shouldSkipProcessingNotification($notification)) {
// Remove notification from collection which will be processed
$notifications->removeItemByKey($notification->getId()); $notifications->removeItemByKey($notification->getId());
continue; continue;
} }
// set Cron processing to true // set notification processing to true
$this->_updateNotification($notification, true, false); $this->_updateNotification($notification, true, false);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment