Refactor Sending::setSubscribers() to use Doctrine instead of Paris

[MAILPOET-4368]
This commit is contained in:
Rodrigo Primo
2023-06-22 14:57:27 -03:00
committed by Aschepikov
parent b252043dac
commit 8fd8b8f193
8 changed files with 145 additions and 16 deletions

View File

@@ -125,6 +125,17 @@ class ScheduledTaskSubscribersRepository extends Repository {
->execute();
}
public function setSubscribers(ScheduledTaskEntity $task, array $subscriberIds): void {
$this->deleteByScheduledTask($task);
foreach ($subscriberIds as $subscriberId) {
$this->createOrUpdate([
'task_id' => $task->getId(),
'subscriber_id' => $subscriberId,
]);
}
}
private function checkCompleted(ScheduledTaskEntity $task): void {
$count = $this->countBy(['task' => $task, 'processed' => ScheduledTaskSubscriberEntity::STATUS_UNPROCESSED]);
if ($count === 0) {