Fix query builder for getting tasks by status

st.deletedAt line was ignored, because the "->where" on the next line replaced it. Resulting query was also wrongy built because of mixing of OR and AND conditions.

[MAILPOET-5755]
This commit is contained in:
 Ján Mikláš
2024-07-02 16:30:28 +02:00
committed by Ján Mikláš
parent d4e42eead7
commit 9236c0ee6a

View File

@@ -244,11 +244,12 @@ class ScheduledTasksRepository extends Repository {
foreach ($statuses as $status) {
$tasksQuery = $this->doctrineRepository->createQueryBuilder('st')
->select('st')
->where('st.deletedAt IS NULL')
->where('st.status = :status');
->where('st.deletedAt IS NULL');
if ($status === ScheduledTaskEntity::VIRTUAL_STATUS_RUNNING) {
$tasksQuery = $tasksQuery->orWhere('st.status IS NULL');
$tasksQuery = $tasksQuery->andWhere('st.status = :status OR st.status IS NULL');
} else {
$tasksQuery = $tasksQuery->andWhere('st.status = :status');
}
if ($type) {