Fix count of tasks on the status page
[MAILPOET-4664]
This commit is contained in:
@@ -218,26 +218,31 @@ class ScheduledTasksRepository extends Repository {
|
|||||||
],
|
],
|
||||||
$limit = Scheduler::TASK_BATCH_SIZE
|
$limit = Scheduler::TASK_BATCH_SIZE
|
||||||
) {
|
) {
|
||||||
|
$result = [];
|
||||||
|
foreach ($statuses as $status) {
|
||||||
|
$tasksQuery = $this->doctrineRepository->createQueryBuilder('st')
|
||||||
|
->select('st')
|
||||||
|
->where('st.deletedAt IS NULL')
|
||||||
|
->where('st.status = :status');
|
||||||
|
|
||||||
$tasksQuery = $this->doctrineRepository->createQueryBuilder('st')
|
if (in_array(ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING, $statuses)) {
|
||||||
->select('st')
|
$tasksQuery = $tasksQuery->orWhere('st.status IS NULL');
|
||||||
->where('st.deletedAt IS NULL')
|
}
|
||||||
->where('st.status IN (:statuses)');
|
|
||||||
|
|
||||||
if (in_array(ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING, $statuses)) {
|
if ($type) {
|
||||||
$tasksQuery = $tasksQuery->orWhere('st.status IS NULL');
|
$tasksQuery = $tasksQuery->andWhere('st.type = :type')
|
||||||
|
->setParameter('type', $type);
|
||||||
|
}
|
||||||
|
|
||||||
|
$tasks = $tasksQuery
|
||||||
|
->setParameter('status', $status)
|
||||||
|
->setMaxResults($limit)
|
||||||
|
->getQuery()
|
||||||
|
->getResult();
|
||||||
|
$result = array_merge($result, $tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type) {
|
return $result;
|
||||||
$tasksQuery = $tasksQuery->andWhere('st.type = :type')
|
|
||||||
->setParameter('type', $type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tasksQuery
|
|
||||||
->setParameter('statuses', $statuses)
|
|
||||||
->setMaxResults($limit)
|
|
||||||
->getQuery()
|
|
||||||
->getResult();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user