Update counts of sending queue when triggering post notification
When we trigger post notification sending we used to create post notification history record, save all scheduled task subscribers but didn't update counts on queue. Counts were eventually updated when sending started. This was causing some issues e.g. when sending got stuck post notification item was showing 0/0 in sending status. Pausing/resuming such a post notification caused that it was immediately set as sent. This commit adds updating counts in queue immediately when sending starts. [MAILPOET-3962]
This commit is contained in:
committed by
Veljko V
parent
bbb23e4f37
commit
6f5cde2fbf
@@ -104,7 +104,7 @@ class Scheduler {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function processPostNotificationNewsletter($newsletter, $queue) {
|
||||
public function processPostNotificationNewsletter($newsletter, SendingTask $queue) {
|
||||
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_POST_NOTIFICATIONS)->addInfo(
|
||||
'process post notification in scheduler',
|
||||
['newsletter_id' => $newsletter->id, 'task_id' => $queue->taskId]
|
||||
@@ -137,6 +137,7 @@ class Scheduler {
|
||||
|
||||
// queue newsletter for delivery
|
||||
$queue->newsletterId = $notificationHistory->id;
|
||||
$queue->updateCount();
|
||||
$queue->status = null;
|
||||
$queue->save();
|
||||
// update notification status
|
||||
|
@@ -522,6 +522,8 @@ class SchedulerTest extends \MailPoetTest {
|
||||
$updatedQueueSubscribers = $updatedQueue->getSubscribers(ScheduledTaskSubscriber::STATUS_UNPROCESSED);
|
||||
expect($updatedQueueSubscribers)->equals([$subscriber->id]);
|
||||
expect($updatedQueue->newsletterId)->equals($notificationHistory->id);
|
||||
expect($updatedQueue->countProcessed)->equals(0);
|
||||
expect($updatedQueue->countToProcess)->equals(1);
|
||||
// set notification history's status to sending
|
||||
$updatedNotificationHistory = Newsletter::where('parent_id', $newsletter->id)
|
||||
->findOne();
|
||||
|
Reference in New Issue
Block a user