Set status of scheduled_task to invalid if it has not subs
[MAILPOET-5134]
This commit is contained in:
@ -200,6 +200,17 @@ class SendingQueue {
|
|||||||
|
|
||||||
// get subscribers
|
// get subscribers
|
||||||
$subscriberBatches = new BatchIterator($queue->taskId, $this->getBatchSize());
|
$subscriberBatches = new BatchIterator($queue->taskId, $this->getBatchSize());
|
||||||
|
if ($subscriberBatches->count() === 0) {
|
||||||
|
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->info(
|
||||||
|
'no subscribers to process',
|
||||||
|
['task_id' => $queue->taskId]
|
||||||
|
);
|
||||||
|
$task = $queue->getSendingQueueEntity()->getTask();
|
||||||
|
if ($task) {
|
||||||
|
$this->scheduledTasksRepository->invalidateTask($task);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
/** @var int[] $subscribersToProcessIds - it's required for PHPStan */
|
/** @var int[] $subscribersToProcessIds - it's required for PHPStan */
|
||||||
foreach ($subscriberBatches as $subscribersToProcessIds) {
|
foreach ($subscriberBatches as $subscribersToProcessIds) {
|
||||||
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->info(
|
$this->loggerFactory->getLogger(LoggerFactory::TOPIC_NEWSLETTERS)->info(
|
||||||
|
@ -309,6 +309,12 @@ class ScheduledTasksRepository extends Repository {
|
|||||||
->getResult();
|
->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function invalidateTask(ScheduledTaskEntity $task): void {
|
||||||
|
$task->setStatus( ScheduledTaskEntity::STATUS_INVALID);
|
||||||
|
$this->persist($task);
|
||||||
|
$this->flush();
|
||||||
|
}
|
||||||
|
|
||||||
protected function findByTypeAndStatus($type, $status, $limit = null, $future = false) {
|
protected function findByTypeAndStatus($type, $status, $limit = null, $future = false) {
|
||||||
$queryBuilder = $this->doctrineRepository->createQueryBuilder('st')
|
$queryBuilder = $this->doctrineRepository->createQueryBuilder('st')
|
||||||
->select('st')
|
->select('st')
|
||||||
|
Reference in New Issue
Block a user