- Removes unused logic to deal with "failed" subscribers

- Updates sending queue worker to handle new mailer response format
This commit is contained in:
Vlad
2016-11-11 19:04:38 -05:00
parent 57dff5ff00
commit 72f696e834
3 changed files with 20 additions and 38 deletions

View File

@ -115,7 +115,6 @@ class Migrator {
'count_total mediumint(9) NOT NULL DEFAULT 0,',
'count_processed mediumint(9) NOT NULL DEFAULT 0,',
'count_to_process mediumint(9) NOT NULL DEFAULT 0,',
'count_failed mediumint(9) NOT NULL DEFAULT 0,',
'scheduled_at TIMESTAMP NULL,',
'processed_at TIMESTAMP NULL,',
'created_at TIMESTAMP NULL,',

View File

@ -21,8 +21,10 @@ class SendingQueue {
$this->mailer_task = ($mailer_task) ? $mailer_task : new MailerTask();
$this->newsletter_task = ($newsletter_task) ? $newsletter_task : new NewsletterTask();
$this->timer = ($timer) ? $timer : microtime(true);
// abort if execution or sending limit are reached
// abort if execution limit is reached
CronHelper::enforceExecutionLimit($this->timer);
// abort if mailing is paused or sending limit has been reached
MailerLog::enforceExecutionRequirements();
}
function process() {
@ -142,20 +144,22 @@ class SendingQueue {
$prepared_newsletters,
$prepared_subscribers
);
if(!$send_result) {
// update failed/to process list
$queue->updateFailedSubscribers($prepared_subscribers_ids);
} else {
// update processed/to process list
$queue->updateProcessedSubscribers($prepared_subscribers_ids);
// log statistics
StatisticsNewslettersModel::createMultiple($statistics);
// update the sent count
$this->mailer_task->updateSentCount();
// enforce sending limit if there are still subscribers left to process
if($queue->count_to_process) {
MailerLog::enforceSendingLimit();
}
// log error message and schedule retry/pause sending
if($send_result['response'] === false) {
MailerLog::processSendingError(
$send_result['operation'],
$send_result['error_message']
);
}
// update processed/to process list
$queue->updateProcessedSubscribers($prepared_subscribers_ids);
// log statistics
StatisticsNewslettersModel::createMultiple($statistics);
// update the sent count
$this->mailer_task->updateSentCount();
// abort if sending limit has been reached
if($queue->count_to_process) {
MailerLog::enforceSendingLimit();
}
return $queue;
}

View File

@ -60,9 +60,6 @@ class SendingQueue extends Model {
if(empty($subscribers['processed'])) {
$subscribers['processed'] = array();
}
if(empty($subscribers['failed'])) {
$subscribers['failed'] = array();
}
return $subscribers;
}
@ -97,22 +94,6 @@ class SendingQueue extends Model {
$this->updateCount();
}
function updateFailedSubscribers($failed_subscribers) {
$subscribers = $this->getSubscribers();
$subscribers['failed'] = array_merge(
$subscribers['failed'],
$failed_subscribers
);
$subscribers['to_process'] = array_values(
array_diff(
$subscribers['to_process'],
$failed_subscribers
)
);
$this->subscribers = $subscribers;
$this->updateCount();
}
function updateProcessedSubscribers($processed_subscribers) {
$subscribers = $this->getSubscribers();
$subscribers['processed'] = array_merge(
@ -131,10 +112,8 @@ class SendingQueue extends Model {
function updateCount() {
$this->subscribers = $this->getSubscribers();
$this->count_processed =
count($this->subscribers['processed']) + count($this->subscribers['failed']);
$this->count_processed = count($this->subscribers['processed']);
$this->count_to_process = count($this->subscribers['to_process']);
$this->count_failed = count($this->subscribers['failed']);
$this->count_total = $this->count_processed + $this->count_to_process;
if(!$this->count_to_process) {
$this->processed_at = current_time('mysql');