From 4e82126bedaf3446a9a568cc0223e882ff64a66e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 12:08:55 +0200 Subject: [PATCH] [activity][export] Fixed: fixed inconsistencies with date filters --- CHANGELOG.md | 1 + .../ActiveOneDayBetweenDatesFilter.php | 19 ++----------------- .../OpenBetweenDatesFilter.php | 14 +++----------- 3 files changed, 6 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1fd7210..2fa9e2bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php index 6e2fa3288..ae9535a67 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/ActiveOneDayBetweenDatesFilter.php @@ -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); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php index a782fdb88..b47f2020d 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/OpenBetweenDatesFilter.php @@ -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); }