Add method for finding scheduled tasks

[MAILPOET-4367]
This commit is contained in:
Jan Lysý
2022-08-11 14:42:38 +02:00
committed by Aschepikov
parent abfab0b0ea
commit 9e7a3c2767

View File

@@ -236,6 +236,27 @@ class ScheduledTasksRepository extends Repository {
->execute(); ->execute();
} }
/**
* @return ScheduledTaskEntity[]
*/
public function findScheduledSendingTasks(int $limit): array {
$now = Carbon::createFromTimestamp($this->wp->currentTime('timestamp'));
return $this->doctrineRepository->createQueryBuilder('st')
->select('st')
->join('st.sendingQueue', 'sq')
->where('st.deletedAt IS NULL')
->andWhere('st.status = :status')
->andWhere('st.scheduledAt <= :now')
->andWhere('st.type = :type')
->orderBy('st.updatedAt', 'ASC')
->setMaxResults($limit)
->setParameter('status', ScheduledTaskEntity::STATUS_SCHEDULED)
->setParameter('now', $now)
->setParameter('type', SendingQueue::TASK_TYPE)
->getQuery()
->getResult();
}
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')