Skip to content

Commit

Permalink
Merged PR 13271: Release V6.4.14
Browse files Browse the repository at this point in the history
- We've fixed a problem with scheduled campaign sends, arising from campaigns stuck in a "Processing" state on Engagement Cloud. In such cases, we will expire campaigns that have been "Processing" for longer than two hours.

Related work items: #86248
  • Loading branch information
Ben Johnson committed Apr 24, 2019
2 parents e4702bf + b038cad commit b005cc9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ You are welcome to contribute to Engagement Cloud for Magento! You can either:
- Fix a bug: please fork this repo and submit the Pull Request to our [Develop branch](https://github.com/dotmailer/dotmailer-magento-extension/tree/develop)
Request a feature on our [roadmap](https://roadmap.dotdigital.com)

# V6.4.14

##### Bug Fixes
- We've fixed a problem with scheduled campaign sends, arising from campaigns stuck in a "Processing" state on Engagement Cloud. In such cases, we will expire campaigns that have been "Processing" for longer than two hours.

# V6.4.13

##### Bug Fixes
Expand Down
31 changes: 31 additions & 0 deletions code/Dotdigitalgroup/Email/Model/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function loadByQuoteId($quoteId, $storeId)
*/
protected function _checkSendStatus($website)
{
$this->expireExpiredCampaigns($website->getStoreIds());
$campaigns = $this->_getEmailCampaigns($website->getStoreIds(), self::PROCESSING, true);
foreach ($campaigns as $campaign) {
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
Expand All @@ -113,6 +114,19 @@ protected function _checkSendStatus($website)
}
}

/**
* @param array $storeIds
*/
private function expireExpiredCampaigns($storeIds)
{
$expiredCampaigns = $this->getExpiredEmailCampaignsByStoreIds($storeIds);
$ids = $expiredCampaigns->getColumnValues('id');
if (! empty($ids)) {
$this->getResource()->expireCampaigns($ids);
}
}


/**
* Sending the campaigns.
*
Expand Down Expand Up @@ -268,4 +282,21 @@ protected function _getEmailCampaigns($storeIds, $sendStatus = 0, $sendIdCheck =
//@codingStandardsIgnoreEnd
return $emailCollection;
}

/**
* @param array $storeIds
* @return Dotdigitalgroup_Email_Model_Resource_Campaign_Collection
*/
private function getExpiredEmailCampaignsByStoreIds($storeIds)
{
$time = Zend_Date::now(Mage::app()->getLocale()->getLocale())->subHour(2);
$campaignCollection = $this->getCollection()
->addFieldToFilter('campaign_id', array('notnull' => true))
->addFieldToFilter('send_status', Dotdigitalgroup_Email_Model_Campaign::PROCESSING)
->addFieldToFilter('store_id', array('in' => $storeIds))
->addFieldToFilter('send_id', array('notnull' => true))
->addFieldToFilter('updated_at', array('lt' => $time->toString('yyyy-MM-dd HH:mm')));

return $campaignCollection;
}
}
19 changes: 19 additions & 0 deletions code/Dotdigitalgroup/Email/Model/Resource/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,23 @@ public function setProcessing($ids, $sendId)
Mage::logException($e);
}
}

/**
* @param array $ids
*/
public function expireCampaigns($ids)
{
$now = Mage::getSingleton('core/date')->gmtDate();
$bind = array(
'send_status' => Dotdigitalgroup_Email_Model_Campaign::SENT,
'message' => 'Check sending status in Engagement Cloud',
'updated_at' => $now
);
$this->_getWriteAdapter()
->update(
$this->getMainTable(),
$bind,
array("id in (?)" => $ids)
);
}
}
2 changes: 1 addition & 1 deletion code/Dotdigitalgroup/Email/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Dotdigitalgroup_Email>
<version>6.4.13</version>
<version>6.4.14</version>
</Dotdigitalgroup_Email>
</modules>
<frontend>
Expand Down

0 comments on commit b005cc9

Please sign in to comment.