[activity][export] Fixed: fixed inconsistencies with date filters

This commit is contained in:
Julien Fastré 2022-09-21 12:08:55 +02:00
parent 8b64933565
commit 4e82126bed
3 changed files with 6 additions and 28 deletions

View File

@ -14,6 +14,7 @@ and this project adheres to
* [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person
* [activity][export] Feature: improve label for aliases in "Filter by activity type"
* [activity][export] DX/Feature: use of an `ActivityTypeRepositoryInterface` instead of the old-style EntityRepository
* [person][export] Fixed: some inconsistency with date filter on accompanying courses
## Test releases

View File

@ -29,24 +29,9 @@ class ActiveOneDayBetweenDatesFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
$clause = "OVERLAPSI (acp.openingDate, acp.closingDate), (:datefrom, :dateto) = 'TRUE'";
$clause = $qb->expr()->orX(
$qb->expr()->lt('(acp.openingDate + 1)', ':dateto'),
$qb->expr()->andX(
$qb->expr()->lt('acp.openingDate', ':datefrom'),
$qb->expr()->isNull('acp.closingDate')
),
$qb->expr()->gt('(acp.closingDate - 1)', ':datefrom')
);
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->andWhere($clause);
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
}

View File

@ -29,20 +29,12 @@ class OpenBetweenDatesFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->andX(
$qb->expr()->lt('acp.openingDate', ':datefrom'),
$qb->expr()->gt('acp.closingDate', ':dateto')
$qb->expr()->gte('acp.openingDate', ':datefrom'),
$qb->expr()->lte('acp.openingDate', ':dateto')
);
if ($where instanceof Andx) {
$where->add($clause);
} else {
$where = $qb->expr()->andX($clause);
}
$qb->add('where', $where);
$qb->andWhere($clause);
$qb->setParameter('datefrom', $data['date_from'], Types::DATE_MUTABLE);
$qb->setParameter('dateto', $data['date_to'], Types::DATE_MUTABLE);
}