Optimize newsletter reactivation

When reactivating a newsletter with many queues (e.g., a welcome email with a long history)
NewsletterEntity::getQueues may fail because it attempts to fetch all queues and instantiate
many entity objects.

In this commit, I optimize this by looking only into unfinished queues.
getUnfinishedQueues look for where countToProcess is higher than 0.
We set the count for welcome emails when we create a new queue
see f1ffc77bf3/mailpoet/lib/Newsletter/Scheduler/WelcomeScheduler.php (L140)
[MAILPOET-6310]
This commit is contained in:
Rostislav Wolny
2024-11-07 14:59:15 +01:00
committed by Aschepikov
parent 1c3ea9cd0a
commit 3fbff8c83f
3 changed files with 4 additions and 3 deletions

View File

@@ -290,7 +290,8 @@ class NewslettersTest extends \MailPoetTest {
SendingQueueWorker::TASK_TYPE,
ScheduledTaskEntity::STATUS_PAUSED,
);
(new SendingQueueFactory())->create($scheduledTask1, $this->postNotification);
$queue = (new SendingQueueFactory())->create($scheduledTask1, $this->postNotification);
$queue->setCountToProcess(1);
$segment = $this->segmentRepository->createOrUpdate('Segment 1');
$this->createNewsletterSegment($this->postNotification, $segment);