Rename function in NewslettersRepository

[MAILPOET-2946]
This commit is contained in:
Jan Lysý
2020-10-22 20:02:37 +02:00
committed by Veljko V
parent 3479783588
commit 080a822135
2 changed files with 7 additions and 5 deletions

View File

@ -322,7 +322,10 @@ class NewslettersRepository extends Repository {
return count($ids);
}
public function existsNotificationHistory(NewsletterEntity $newsletter): bool {
/**
* @return NewsletterEntity[]
*/
public function findSendigNotificationHistoryWithPausedTask(NewsletterEntity $newsletter): array {
$result = $this->entityManager->createQueryBuilder()
->select('n')
->from(NewsletterEntity::class, 'n')
@ -336,9 +339,8 @@ class NewslettersRepository extends Repository {
->setParameter('type', NewsletterEntity::TYPE_NOTIFICATION_HISTORY)
->setParameter('status', NewsletterEntity::STATUS_SENDING)
->setParameter('taskStatus', ScheduledTaskEntity::STATUS_PAUSED)
->setMaxResults(1)
->getQuery()->execute();
return count($result) > 0;
return $result;
}
public function prefetchOptions(array $newsletters) {

View File

@ -91,8 +91,8 @@ class PostNotificationScheduler {
}
public function createPostNotificationSendingTask(NewsletterEntity $newsletter): ?SendingTask {
$notificationHistoryExists = $this->newslettersRepository->existsNotificationHistory($newsletter);
if ($notificationHistoryExists) {
$notificationHistory = $this->newslettersRepository->findSendigNotificationHistoryWithPausedTask($newsletter);
if (count($notificationHistory) > 0) {
return null;
}