Add method for processing end of sending for completed tasks
[MAILPOET-5881]
This commit is contained in:
committed by
Aschepikov
parent
1111bac58b
commit
55ae6264cc
@@ -334,13 +334,11 @@ class SendingQueue {
|
|||||||
'after queue chunk processing',
|
'after queue chunk processing',
|
||||||
['newsletter_id' => $newsletter->getId(), 'task_id' => $task->getId()]
|
['newsletter_id' => $newsletter->getId(), 'task_id' => $task->getId()]
|
||||||
);
|
);
|
||||||
|
// In case we finished end sending properly before enforcing sending and execution limits
|
||||||
|
// The limit enforcing throws and exception and the sending end wouldn't be processed properly (stats notification, newsletter marked as sent etc.)
|
||||||
if ($task->getStatus() === ScheduledTaskEntity::STATUS_COMPLETED) {
|
if ($task->getStatus() === ScheduledTaskEntity::STATUS_COMPLETED) {
|
||||||
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->info(
|
$this->endSending($task, $newsletter);
|
||||||
'completed newsletter sending',
|
return;
|
||||||
['newsletter_id' => $newsletter->getId(), 'task_id' => $task->getId()]
|
|
||||||
);
|
|
||||||
$this->newsletterTask->markNewsletterAsSent($newsletter);
|
|
||||||
$this->statsNotificationsScheduler->schedule($newsletter);
|
|
||||||
}
|
}
|
||||||
$this->enforceSendingAndExecutionLimits($timer);
|
$this->enforceSendingAndExecutionLimits($timer);
|
||||||
} else {
|
} else {
|
||||||
@@ -641,4 +639,16 @@ class SendingQueue {
|
|||||||
$this->scheduledTasksRepository->remove($task);
|
$this->scheduledTasksRepository->remove($task);
|
||||||
$this->scheduledTasksRepository->flush();
|
$this->scheduledTasksRepository->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function endSending(ScheduledTaskEntity $task, NewsletterEntity $newsletter): void {
|
||||||
|
// Task is completed let's do all the stuff for the completed task
|
||||||
|
if ($task->getStatus() === ScheduledTaskEntity::STATUS_COMPLETED) {
|
||||||
|
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->info(
|
||||||
|
'completed newsletter sending',
|
||||||
|
['newsletter_id' => $newsletter->getId(), 'task_id' => $task->getId()]
|
||||||
|
);
|
||||||
|
$this->newsletterTask->markNewsletterAsSent($newsletter);
|
||||||
|
$this->statsNotificationsScheduler->schedule($newsletter);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user