add filtering in task list

This commit is contained in:
2021-10-27 13:32:52 +02:00
parent 691c5ffd21
commit f4fb375fd1
4 changed files with 97 additions and 3 deletions

View File

@@ -61,6 +61,66 @@ final class SingleTaskAclAwareRepository implements SingleTaskAclAwareRepository
->setParameter('user', $this->security->getUser())
;
if (!empty($pattern)) {
$qb->andWhere($qb->expr()->like('LOWER(UNACCENT(t.title))', 'LOWER(UNACCENT(:pattern))'))
->setParameter('pattern', $pattern)
;
}
if (count($flags) > 0) {
$orX = $qb->expr()->orX();
$now = new \DateTime();
if (\in_array('no-alert', $flags)) {
$orX
->add(
$qb->expr()->orX(
$qb->expr()->isNull('t.endDate'),
$qb->expr()->gte('t.endDate - COALESCE(t.warningInterval, :intervalBlank)', ':now')
)
);
$qb
->setParameter('intervalBlank', new \DateInterval('P0D'))
->setParameter('now', $now)
;
}
if (\in_array('warning', $flags)) {
$orX
->add(
$qb->expr()->andX(
$qb->expr()->eq('t.closed', "'FALSE'"),
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->not($qb->expr()->isNull('t.warningInterval')),
$qb->expr()->lte('t.endDate - t.warningInterval', ':now')
)
)
;
$qb
->setParameter('now', $now)
;
}
if (\in_array('alert', $flags)) {
$orX
->add(
$qb->expr()->andX(
$qb->expr()->eq('t.closed', "'FALSE'"),
$qb->expr()->not($qb->expr()->isNull('t.endDate')),
$qb->expr()->lte('t.endDate', ':now')
)
)
;
$qb
->setParameter('now', $now)
;
}
$qb->andWhere($orX);
}
return $qb;
}