Update checkCompleted() to also change the processedAt field

This commit updates the method ScheduledTaskSubscribersRepository::checkCompleted() to update the processedAt field of the Scheduled Task. The method was added in f62d9b4167 and I believe it is meant to be a replacement to \MailPoet\Tasks\Subscribers::checkCompleted(). The original method updates the processedAt field, so I'm assuming the new method should update as well. I found this while working on refactoring \MailPoet\Tasks\Sending::removeSubscribers() to use Doctrine as this method calls \MailPoet\Tasks\Subscribers::checkCompleted() internaly.

[MAILPOET-4368]
This commit is contained in:
Rodrigo Primo
2023-07-06 11:48:47 -03:00
committed by Aschepikov
parent 9c766c2f32
commit 59d4ce3ba2

View File

@@ -7,6 +7,7 @@ use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Entities\ScheduledTaskSubscriberEntity; use MailPoet\Entities\ScheduledTaskSubscriberEntity;
use MailPoet\Entities\SubscriberEntity; use MailPoet\Entities\SubscriberEntity;
use MailPoet\InvalidStateException; use MailPoet\InvalidStateException;
use MailPoetVendor\Carbon\Carbon;
use MailPoetVendor\Doctrine\DBAL\Connection; use MailPoetVendor\Doctrine\DBAL\Connection;
use MailPoetVendor\Doctrine\ORM\QueryBuilder; use MailPoetVendor\Doctrine\ORM\QueryBuilder;
@@ -140,6 +141,7 @@ class ScheduledTaskSubscribersRepository extends Repository {
$count = $this->countBy(['task' => $task, 'processed' => ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED]); $count = $this->countBy(['task' => $task, 'processed' => ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED]);
if ($count === 0) { if ($count === 0) {
$task->setStatus(ScheduledTaskEntity::STATUS_COMPLETED); $task->setStatus(ScheduledTaskEntity::STATUS_COMPLETED);
$task->setProcessedAt(new Carbon());
$this->entityManager->flush(); $this->entityManager->flush();
} }
} }