Use doctrine in stats notifications for auto emails

[MAILPOET-2439]
This commit is contained in:
Pavel Dohnal
2019-10-28 12:42:21 +01:00
committed by Jack Kitterhing
parent 5a2edff9fe
commit 95564cfa32
4 changed files with 138 additions and 92 deletions

View File

@ -4,6 +4,7 @@ namespace MailPoet\Cron\Workers\StatsNotifications;
use Carbon\Carbon;
use MailPoet\Doctrine\Repository;
use MailPoet\Entities\NewsletterEntity;
use MailPoet\Entities\ScheduledTaskEntity;
use MailPoet\Entities\StatsNotificationEntity;
@ -56,5 +57,24 @@ class StatsNotificationsRepository extends Repository {
}
return $query->getQuery()->getResult();
}
/**
* @return NewsletterEntity[]
*/
public function getDueAutomatedNewsletters() {
return $this->entity_manager
->createQueryBuilder()
->select('n')
->from(NewsletterEntity::class, 'n')
->where('n.status = :status')
->setParameter(':status', NewsletterEntity::STATUS_ACTIVE)
->andWhere('n.deleted_at is null')
->andWhere('n.type IN (:types)')
->setParameter('types', [NewsletterEntity::TYPE_AUTOMATIC, NewsletterEntity::TYPE_WELCOME])
->orderBy('n.subject')
->getQuery()
->getResult();
}
}