From 59b22dbb6dbc898d42cee26ac38a5b031918c3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 20 Sep 2022 17:02:35 +0200 Subject: [PATCH 01/17] [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person --- CHANGELOG.md | 1 + ...bstractAccompanyingPeriodExportElement.php | 20 ++++++++++--------- .../AccompanyingPeriodClosingFilter.php | 4 ++-- .../AccompanyingPeriodFilter.php | 6 +++--- .../AccompanyingPeriodOpeningFilter.php | 4 ++-- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 030b4ba33..f4e0ab7f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [person][export] Fixed: rename the alias for `accompanying_period` to `acp` in filter associated with person ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php b/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php index 264f47955..d7c98a7d7 100644 --- a/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php +++ b/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php @@ -25,13 +25,17 @@ class AbstractAccompanyingPeriodExportElement */ protected function addJoinAccompanyingPeriod(QueryBuilder $query): void { - if (false === $this->havingAccompanyingPeriodInJoin($query)) { - if (false === in_array('person', $query->getAllAliases(), true)) { - throw new LogicException("the alias 'person' does not exists in " - . 'query builder'); - } + if (false === in_array('person', $query->getAllAliases(), true)) { + throw new LogicException("the alias 'person' does not exists in " + . 'query builder'); + } - $query->join('person.accompanyingPeriods', 'accompanying_period'); + if (!in_array('acppart', $query->getAllAliases(), true)) { + $query->join('person.accompanyingPeriodParticipations', 'acppart'); + } + + if (!in_array('acp', $query->getAllAliases(), true)) { + $query->join('acppart.accompanyingPeriod', 'acp'); } } @@ -40,8 +44,6 @@ class AbstractAccompanyingPeriodExportElement */ protected function havingAccompanyingPeriodInJoin(QueryBuilder $query): bool { - $joins = $query->getDQLPart('join') ?? []; - - return in_array('accompanying_period', $query->getAllAliases(), true); + return in_array('acp', $query->getAllAliases(), true); } } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php index e56782847..9258c9b0a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilter.php @@ -32,8 +32,8 @@ class AccompanyingPeriodClosingFilter extends AbstractAccompanyingPeriodExportEl $this->addJoinAccompanyingPeriod($qb); $clause = $qb->expr()->andX( - $qb->expr()->lte('accompanying_period.closingDate', ':date_to'), - $qb->expr()->gte('accompanying_period.closingDate', ':date_from') + $qb->expr()->lte('acp.closingDate', ':date_to'), + $qb->expr()->gte('acp.closingDate', ':date_from') ); $qb->andWhere($clause); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php index 5a7ccb4a3..0c97ac6bf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodFilter.php @@ -34,12 +34,12 @@ class AccompanyingPeriodFilter extends AbstractAccompanyingPeriodExportElement i $clause = $qb->expr()->andX(); $clause->add( - $qb->expr()->lte('accompanying_period.openingDate', ':date_to') + $qb->expr()->lte('acp.openingDate', ':date_to') ); $clause->add( $qb->expr()->orX( - $qb->expr()->gte('accompanying_period.closingDate', ':date_from'), - $qb->expr()->isNull('accompanying_period.closingDate') + $qb->expr()->gte('acp.closingDate', ':date_from'), + $qb->expr()->isNull('acp.closingDate') ) ); diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php index 33805d392..00ff885ba 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilter.php @@ -32,8 +32,8 @@ class AccompanyingPeriodOpeningFilter extends AbstractAccompanyingPeriodExportEl $this->addJoinAccompanyingPeriod($qb); $clause = $qb->expr()->andX( - $qb->expr()->lte('accompanying_period.openingDate', ':date_to'), - $qb->expr()->gte('accompanying_period.openingDate', ':date_from') + $qb->expr()->lte('acp.openingDate', ':date_to'), + $qb->expr()->gte('acp.openingDate', ':date_from') ); $qb->andWhere($clause); From 052c0e1969184139a2df42fe77c48de6f1199a5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 20 Sep 2022 18:50:04 +0200 Subject: [PATCH 02/17] [CS] remove dead code --- .../Export/AbstractAccompanyingPeriodExportElement.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php b/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php index d7c98a7d7..4fa0b9ad8 100644 --- a/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php +++ b/src/Bundle/ChillPersonBundle/Export/AbstractAccompanyingPeriodExportElement.php @@ -38,12 +38,4 @@ class AbstractAccompanyingPeriodExportElement $query->join('acppart.accompanyingPeriod', 'acp'); } } - - /** - * Return true if "accompanying_period" alias is present in the query alises. - */ - protected function havingAccompanyingPeriodInJoin(QueryBuilder $query): bool - { - return in_array('acp', $query->getAllAliases(), true); - } } From 42c395ecc9221e0d88c8a7792cd583cf8f377a3a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 20 Sep 2022 17:12:41 +0200 Subject: [PATCH 03/17] export: add logger to make feedback on deployed instances easier to debug --- src/Bundle/ChillMainBundle/Controller/ExportController.php | 6 ++++++ src/Bundle/ChillMainBundle/Export/ExportManager.php | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index ffd73b777..4ced2cacc 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -442,6 +442,12 @@ class ExportController extends AbstractController } $rawData = unserialize($serialized); + + $this->logger->notice('[export] choices for an export unserialized', [ + 'key' => $key, + 'rawData' => json_encode($rawData) + ]); + $alias = $rawData['alias']; $formCenters = $this->createCreateFormExport($alias, 'generate_centers'); diff --git a/src/Bundle/ChillMainBundle/Export/ExportManager.php b/src/Bundle/ChillMainBundle/Export/ExportManager.php index c1384a3b8..df14a8ac8 100644 --- a/src/Bundle/ChillMainBundle/Export/ExportManager.php +++ b/src/Bundle/ChillMainBundle/Export/ExportManager.php @@ -264,15 +264,17 @@ class ExportManager //handle aggregators $this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers); - $this->logger->debug('current query is ' . $query->getDQL(), [ - 'class' => self::class, 'function' => __FUNCTION__, + $this->logger->notice('[export] will execute this qb in export', [ + 'dql' => $query->getDQL() ]); + } else { throw new UnexpectedValueException('The method `intiateQuery` should return ' . 'a `\\Doctrine\\ORM\\NativeQuery` or a `Doctrine\\ORM\\QueryBuilder` ' . 'object.'); } + $result = $export->getResult($query, $data[ExportType::EXPORT_KEY]); if (!is_iterable($result)) { From d599792de88e5fc7daccab34dad9eb5361385624 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 10:16:08 +0200 Subject: [PATCH 04/17] enable commented filter (!?) --- .../config/services/exports_social_actions.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index 9b257e684..450899659 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -9,12 +9,12 @@ services: ## FILTERS - #chill.person.export.filter_social_work_type: - # class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter - # autowire: true - # autoconfigure: true - # tags: - # - { name: chill.export_filter, alias: social_work_type_filter } + chill.person.export.filter_social_work_type: + class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\SocialWorkTypeFilter + autowire: true + autoconfigure: true + tags: + - { name: chill.export_filter, alias: social_work_type_filter } chill.person.export.filter_scope: class: Chill\PersonBundle\Export\Filter\SocialWorkFilters\ScopeFilter From b25a1c3cbb63eae58aaa01ef25d45724a86c716e Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 19 Sep 2022 17:01:00 +0200 Subject: [PATCH 05/17] correct import path with filter/aggr --- .../Export/Aggregator/ActivityReasonAggregatorTest.php | 6 ++---- .../Tests/Export/Aggregator/ActivityTypeAggregatorTest.php | 6 ++---- .../Tests/Export/Aggregator/ActivityUserAggregatorTest.php | 6 ++---- .../Tests/Export/Filter/ActivityReasonFilterTest.php | 6 ++---- .../Filter/PersonHavingActivityBetweenDateFilterTest.php | 6 ++---- .../Aggregator/PersonAggregators/AgeAggregatorTest.php | 6 ++---- .../Aggregator/PersonAggregators/GenderAggregatorTest.php | 6 ++---- .../PersonAggregators/NationalityAggregatorTest.php | 6 ++---- .../AccompanyingCourseFilters/CurrentUserJobFilterTest.php | 4 ++-- .../CurrentUserScopeFilterTest.php | 4 ++-- .../Filter/PersonFilters/AccompanyingPeriodFilterTest.php | 4 ++-- .../{BirthdayFilterTest.php => BirthdateFilterTest.php} | 2 +- 12 files changed, 23 insertions(+), 39 deletions(-) rename src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/{BirthdayFilterTest.php => BirthdateFilterTest.php} (96%) diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityReasonAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityReasonAggregatorTest.php index 436bfc697..79c0924f7 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityReasonAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityReasonAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; +use Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityReasonAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; /** @@ -21,10 +22,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; */ final class ActivityReasonAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator - */ - private $aggregator; + private ActivityReasonAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php index f6efe17a5..bd88a7d3b 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityTypeAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; +use Chill\ActivityBundle\Export\Aggregator\PersonAggregators\ActivityTypeAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; /** @@ -21,10 +22,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; */ final class ActivityTypeAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\ActivityBundle\Export\Aggregator\ActivityReasonAggregator - */ - private $aggregator; + private ActivityTypeAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php index 1447f473b..0e620040f 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ActivityUserAggregatorTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; +use Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; /** @@ -21,10 +22,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; */ final class ActivityUserAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\ActivityBundle\Export\Aggregator\ActivityUserAggregator - */ - private $aggregator; + private ActivityUserAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php index 5b8ae08c3..72f052f54 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityReasonFilterTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Filter; +use Chill\ActivityBundle\Export\Filter\PersonFilters\ActivityReasonFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use Doctrine\Common\Collections\ArrayCollection; @@ -20,10 +21,7 @@ use Doctrine\Common\Collections\ArrayCollection; */ final class ActivityReasonFilterTest extends AbstractFilterTest { - /** - * @var \Chill\PersonBundle\Export\Filter\GenderFilter - */ - private $filter; + private ActivityReasonFilter $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php index 94d99c2a7..507f03323 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonHavingActivityBetweenDateFilterTest.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Filter; +use Chill\ActivityBundle\Export\Filter\PersonFilters\PersonHavingActivityBetweenDateFilter; use Chill\MainBundle\Test\Export\AbstractFilterTest; use DateTime; use function array_slice; @@ -21,10 +22,7 @@ use function array_slice; */ final class PersonHavingActivityBetweenDateFilterTest extends AbstractFilterTest { - /** - * @var \Chill\PersonBundle\Export\Filter\PersonHavingActivityBetweenDateFilter - */ - private $filter; + private PersonHavingActivityBetweenDateFilter $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php index a0d869462..031ded74c 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/AgeAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator; use DateTime; /** @@ -20,10 +21,7 @@ use DateTime; */ final class AgeAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\AgeAggregator - */ - private $aggregator; + private AgeAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php index 6389ac33d..16bca62d9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/GenderAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator; /** * @internal @@ -19,10 +20,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; */ final class GenderAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\GenderAggregator - */ - private $aggregator; + private GenderAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php index c093d96cc..7de9587eb 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/NationalityAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\PersonAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator; /** * @internal @@ -19,10 +20,7 @@ use Chill\MainBundle\Test\Export\AbstractAggregatorTest; */ final class NationalityAggregatorTest extends AbstractAggregatorTest { - /** - * @var \Chill\PersonBundle\Export\Aggregator\PersonAggregators\NationalityAggregator - */ - private $aggregator; + private NationalityAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilterTest.php index 77881a218..ab2c703b6 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserJobFilterTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserJobFilter; +use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserJobFilter; use Doctrine\ORM\EntityManagerInterface; /** @@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface; */ final class CurrentUserJobFilterTest extends AbstractFilterTest { - private UserJobFilter $filter; + private CurrentUserJobFilter $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilterTest.php index 1ea4d40b0..d4f4712bc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/CurrentUserScopeFilterTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Filter\AccompanyingCourseFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\UserScopeFilter; +use Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\CurrentUserScopeFilter; use Doctrine\ORM\EntityManagerInterface; /** @@ -21,7 +21,7 @@ use Doctrine\ORM\EntityManagerInterface; */ final class CurrentUserScopeFilterTest extends AbstractFilterTest { - private UserScopeFilter $filter; + private CurrentUserScopeFilter $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php index fb975000a..943f20d73 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodFilterTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Filter\PersonFilters; use Chill\MainBundle\Test\Export\AbstractFilterTest; -use Chill\PersonBundle\Export\Filter\PersonFilters\BirthdateFilter; +use Chill\PersonBundle\Export\Filter\PersonFilters\AccompanyingPeriodFilter; use DateTime; use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; @@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; */ final class AccompanyingPeriodFilterTest extends AbstractFilterTest { - private BirthdateFilter $filter; + private AccompanyingPeriodFilter $filter; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdayFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdateFilterTest.php similarity index 96% rename from src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdayFilterTest.php rename to src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdateFilterTest.php index 4ff4f5ce3..68664b8b7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdayFilterTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/BirthdateFilterTest.php @@ -19,7 +19,7 @@ use DateTime; * @internal * @coversNothing */ -final class BirthdayFilterTest extends AbstractFilterTest +final class BirthdateFilterTest extends AbstractFilterTest { private BirthdateFilter $filter; From 37dcbe92c043ac1a9ec9d404927872c1e0de8643 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 20 Sep 2022 14:46:52 +0200 Subject: [PATCH 06/17] export: fix translation --- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index ddaf847c2..557a6a24b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -386,7 +386,7 @@ Deathdate before: Décédé avant cette date Alive: Vivant Deceased: Décédé Filter in relation to this date: Filtrer par rapport à cette date -"Filtered by a state of %deadOrAlive% at this date %date_calc%": Filtré par personnes qui sont %deadOrAlive% à cette date %date_calc% +"Filtered by a state of %deadOrAlive%: at this date %date_calc%": Filtré par personnes qui sont %deadOrAlive% à cette date %date_calc% Filter by person's age: Filtrer les personnes par age "Filtered by person's age: between %min_age% and %max_age%": "Filtré par âge de la personne entre %min_age% et %max_age%" From 390009b39501da63ce2a7b7c2c1a96be30843b65 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 19 Sep 2022 19:32:13 +0200 Subject: [PATCH 07/17] export: create new filter tests --- .../PersonHavingActivityBetweenDateFilter.php | 5 +- .../ACPFilters/ActivityTypeFilterTest.php | 85 ++++++++++++++ .../ACPFilters/BySocialActionFilterTest.php | 82 +++++++++++++ .../ACPFilters/BySocialIssueFilterTest.php | 83 +++++++++++++ .../Filter/ACPFilters/ByUserFilterTest.php | 82 +++++++++++++ .../Filter/ACPFilters/EmergencyFilterTest.php | 67 +++++++++++ .../ACPFilters/LocationTypeFilterTest.php | 82 +++++++++++++ .../ACPFilters/SentReceivedFilterTest.php | 67 +++++++++++ .../Filter/ACPFilters/UserFilterTest.php | 81 +++++++++++++ .../Filter/ACPFilters/UserScopeFilterTest.php | 82 +++++++++++++ .../Export/Filter/ActivityDateFilterTest.php | 69 +++++++++++ .../Export/Filter/ActivityTypeFilterTest.php | 81 +++++++++++++ .../ActivityReasonFilterTest.php | 82 +++++++++++++ ...sonHavingActivityBetweenDateFilterTest.php | 83 +++++++++++++ .../EvaluationTypeFilterTest.php | 83 +++++++++++++ .../EvaluationFilters/MaxDateFilterTest.php | 70 +++++++++++ .../CompositionFilterTest.php | 82 +++++++++++++ .../AccompanyingPeriodClosingFilterTest.php | 89 ++++++++++++++ .../AccompanyingPeriodOpeningFilterTest.php | 89 ++++++++++++++ .../Filter/PersonFilters/AgeFilterTest.php | 75 ++++++++++++ .../PersonFilters/DeadOrAliveFilterTest.php | 73 ++++++++++++ .../PersonFilters/DeathdateFilterTest.php | 69 +++++++++++ .../PersonFilters/MaritalStatusFilterTest.php | 83 +++++++++++++ .../PersonFilters/NationalityFilterTest.php | 78 ++++++++++++ ...sidentialAddressAtThirdpartyFilterTest.php | 89 ++++++++++++++ .../ResidentialAddressAtUserFilterTest.php | 69 +++++++++++ .../SocialWorkFilters/ReferrerFilterTest.php | 77 ++++++++++++ .../SocialWorkTypeFilterTest.php | 111 ++++++++++++++++++ 28 files changed, 2166 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php index 871271aaa..c15411b4e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilter.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Filter\PersonFilters; +use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Repository\ActivityReasonRepository; use Chill\MainBundle\Export\ExportElementValidatedInterface; @@ -59,10 +60,10 @@ class PersonHavingActivityBetweenDateFilter implements ExportElementValidatedInt public function alterQuery(QueryBuilder $qb, $data) { - // create a query for activity + // create a subquery for activity $sqb = $qb->getEntityManager()->createQueryBuilder(); $sqb->select('person_person_having_activity.id') - ->from('ChillActivityBundle:Activity', 'activity_person_having_activity') + ->from(Activity::class, 'activity_person_having_activity') ->join('activity_person_having_activity.person', 'person_person_having_activity'); // add clause between date diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php new file mode 100644 index 000000000..1be583bb6 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php @@ -0,0 +1,85 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_activitytype'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(ActivityType::class, 'at') + ->select('at') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_activitytypes' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join(Activity::class, 'activity', Expr\Join::WITH, 'activity.accompanyingPeriod = acp') + ->join('activity.activityType', 'acttype'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php new file mode 100644 index 000000000..1480e3569 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialActionFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.bysocialaction_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(SocialAction::class, 'sa') + ->select('sa') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_socialactions' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.socialActions', 'actsocialaction'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php new file mode 100644 index 000000000..6af3ea97c --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/BySocialIssueFilterTest.php @@ -0,0 +1,83 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.bysocialissue_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(SocialIssue::class, 'si') + ->select('si') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_socialissues' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.socialIssues', 'actsocialissue') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php new file mode 100644 index 000000000..93810433d --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ByUserFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.byuser_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(User::class, 'u') + ->select('u') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_users' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.users', 'actusers'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php new file mode 100644 index 000000000..d90523bed --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/EmergencyFilterTest.php @@ -0,0 +1,67 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.emergency_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + ['accepted_emergency' => true ], + ['accepted_emergency' => false ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php new file mode 100644 index 000000000..dcac884b9 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/LocationTypeFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.locationtype_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(LocationType::class, 'lt') + ->select('lt') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_locationtype' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.location', 'actloc'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php new file mode 100644 index 000000000..b40443ee4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/SentReceivedFilterTest.php @@ -0,0 +1,67 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.sentreceived_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + ['accepted_sentreceived' => Activity::SENTRECEIVED_SENT ], + ['accepted_sentreceived' => Activity::SENTRECEIVED_RECEIVED ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php new file mode 100644 index 000000000..cc1a1b81a --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserFilterTest.php @@ -0,0 +1,81 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.user_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(User::class, 'u') + ->select('u') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_users' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php new file mode 100644 index 000000000..31ff8ca57 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/UserScopeFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.userscope_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(Scope::class, 's') + ->select('s') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'accepted_userscope' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.user', 'actuser'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php new file mode 100644 index 000000000..b65d3808d --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityDateFilterTest.php @@ -0,0 +1,69 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.date_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-01-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2021-01-01'), + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php new file mode 100644 index 000000000..12ace7c67 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ActivityTypeFilterTest.php @@ -0,0 +1,81 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.type_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(ActivityType::class, 'at') + ->select('at') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'types' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php new file mode 100644 index 000000000..e6b14b44c --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/ActivityReasonFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.reason_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(ActivityReason::class, 'ar') + ->select('ar') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'reasons' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.reasons', 'actreasons'), + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php new file mode 100644 index 000000000..5cad68da4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/PersonFilters/PersonHavingActivityBetweenDateFilterTest.php @@ -0,0 +1,83 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.activity.export.person_having_an_activity_between_date_filter'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(ActivityReason::class, 'ar') + ->select('ar') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $a) { + $data[] = [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'), + 'reasons' => $a + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php new file mode 100644 index 000000000..8ba2b46c1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/EvaluationTypeFilterTest.php @@ -0,0 +1,83 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_evaluationtype'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(Evaluation::class, 'e') + ->select('e') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $r) { + $data[] = [ + 'accepted_evaluationtype' => $r + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('workeval.id') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php new file mode 100644 index 000000000..5c9533850 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/EvaluationFilters/MaxDateFilterTest.php @@ -0,0 +1,70 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_maxdate'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + ['maxdate' => false ], + ['maxdate' => true ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('workeval.id') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php new file mode 100644 index 000000000..6892c0afc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/HouseholdFilters/CompositionFilterTest.php @@ -0,0 +1,82 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_household_composition'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(HouseholdCompositionType::class, 'r') + ->select('r') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $r) { + $data[] = [ + 'accepted_composition' => $r, + 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('h.id') + ->from(Household::class, 'h'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php new file mode 100644 index 000000000..bf975c5a1 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodClosingFilterTest.php @@ -0,0 +1,89 @@ +filter = self::$container->get('chill.person.export.filter_accompanying_period_closing'); + } catch (ServiceNotFoundException $e) { + $this->markTestSkipped('The current configuration does not use accompanying_periods'); + } + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'), + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container + ->get('doctrine.orm.entity_manager'); + + return [ + $em->createQueryBuilder() + ->select('person.firstName') + ->from('ChillPersonBundle:Person', 'person'), + $em->createQueryBuilder() + ->select('person.firstName') + ->from('ChillPersonBundle:Person', 'person') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('count(IDENTITY(p))') + ->from('ChillPersonBundle:Person', 'person') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('count(IDENTITY(p))') + ->from('ChillPersonBundle:Person', 'person') + ->join('person.accompanyingPeriods', 'accompanying_period') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('activity.date AS date') + ->select('activity.attendee as attendee') + ->from('ChillActivityBundle:Activity', 'activity') + ->join('activity.person', 'person') + ->join('person.center', 'center'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php new file mode 100644 index 000000000..54ed981ec --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AccompanyingPeriodOpeningFilterTest.php @@ -0,0 +1,89 @@ +filter = self::$container->get('chill.person.export.filter_accompanying_period_opening'); + } catch (ServiceNotFoundException $e) { + $this->markTestSkipped('The current configuration does not use accompanying_periods'); + } + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2000-01-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2010-01-01'), + ], + ]; + } + + public function getQueryBuilders() + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container + ->get('doctrine.orm.entity_manager'); + + return [ + $em->createQueryBuilder() + ->select('person.firstName') + ->from('ChillPersonBundle:Person', 'person'), + $em->createQueryBuilder() + ->select('person.firstName') + ->from('ChillPersonBundle:Person', 'person') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('count(IDENTITY(p))') + ->from('ChillPersonBundle:Person', 'person') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('count(IDENTITY(p))') + ->from('ChillPersonBundle:Person', 'person') + ->join('person.accompanyingPeriods', 'accompanying_period') + // add a dummy where clause + ->where('person.firstname IS NOT NULL'), + $em->createQueryBuilder() + ->select('activity.date AS date') + ->select('activity.attendee as attendee') + ->from('ChillActivityBundle:Activity', 'activity') + ->join('activity.person', 'person') + ->join('person.center', 'center'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php new file mode 100644 index 000000000..30ca43dfd --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/AgeFilterTest.php @@ -0,0 +1,75 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_age'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'min_age' => '18', + 'max_age' => '60', + 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), + ], + [ // ça devrait faire boum ! + 'min_age' => '35', + 'max_age' => '30', + 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php new file mode 100644 index 000000000..ea2fa62cb --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeadOrAliveFilterTest.php @@ -0,0 +1,73 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_dead_or_alive'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'person_state' => 'alive', + 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'), + ], + [ + 'person_state' => 'deceased', + 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2021-05-01'), + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php new file mode 100644 index 000000000..cb711af43 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/DeathdateFilterTest.php @@ -0,0 +1,69 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_deathdate'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2020-05-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php new file mode 100644 index 000000000..8ce747f63 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/MaritalStatusFilterTest.php @@ -0,0 +1,83 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_marital_status'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(MaritalStatus::class, 'm') + ->select('m') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $m) { + $data[] = [ + 'maritalStatus' => $m, + 'calc_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p'), + ]; + } +} + diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php new file mode 100644 index 000000000..4ea2c44cc --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/NationalityFilterTest.php @@ -0,0 +1,78 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_nationality'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $countries = $em->getRepository(Country::class)->findAll(); + + $data = []; + + foreach ($countries as $c) { + $data[] = [ + 'nationalities' => $c + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p'), + ]; + } + +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php new file mode 100644 index 000000000..8bd07f75c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtThirdpartyFilterTest.php @@ -0,0 +1,89 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_residential_address_at_thirdparty'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $array = $em->createQueryBuilder() + ->from(ThirdPartyCategory::class, 'tpc') + ->select('tpc') + ->getQuery() + ->getResult(); + + $data = []; + + foreach ($array as $r) { + $data[] = [ + 'thirdparty_cat' => $r, + 'date_calc' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'), + ]; + } + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p') + ->join(ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p') + ->join('p.center', 'center') + ->join('resaddr.hostThirdParty', 'tparty') + ->join('tparty.categories', 'tpartycat') + , + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php new file mode 100644 index 000000000..6a2cde4b0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/PersonFilters/ResidentialAddressAtUserFilterTest.php @@ -0,0 +1,69 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_residential_address_at_user'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return []; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('p.id') + ->from(Person::class, 'p') + ->join(Person\ResidentialAddress::class, 'resaddr', Expr\Join::WITH, 'resaddr.person = p') + ->join('p.center', 'center'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php new file mode 100644 index 000000000..c5cc9c523 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/ReferrerFilterTest.php @@ -0,0 +1,77 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_treatingagent'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $em = self::$container->get(EntityManagerInterface::class); + + $users = $em->getRepository(User::class)->findAll(); + + $data = []; + + foreach ($users as $u) { + $data[] = [ + 'accepted_agents' => $u + ]; + } + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('acpw.id') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw'), + ]; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php new file mode 100644 index 000000000..2e3b392ae --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/SocialWorkTypeFilterTest.php @@ -0,0 +1,111 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.person.export.filter_social_work_type'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + $action_repository = self::$container->get(SocialActionRepository::class); + $goal_repository = self::$container->get(GoalRepository::class); + $result_repository = self::$container->get(ResultRepository::class); + + $actions = []; + $goals = []; + $results = []; + + $social_actions = $action_repository->findAll(); + foreach ($social_actions as $action) { + $actions[] = $action->getId(); + $goals_by_action = $goal_repository->findBySocialActionWithDescendants($action); + foreach ($goals_by_action as $goal) { + $goals[] = $goal->getId(); + $results_by_goal = $result_repository->findByGoal($goal); + foreach ($results_by_goal as $result) { + $results[] = $result->getId(); + } + } + $results_by_action = $result_repository->findBySocialActionWithDescendants($action); + foreach ($results_by_action as $result) { + $results[] = $result->getId(); + } + } + + sort($actions); + sort($goals); + sort($results); + + $actions = array_unique($actions); + $goals = array_unique($goals); + $results = array_unique($results); + + $data = [ + [ + 'actionType' => implode(',', $actions), + 'goal' => implode(',', $goals), + 'result' => implode(',', $results), + ] + ]; + /// TODO ne fonctionne pas + var_dump($data); + + return $data; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('acpw.id') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw'), + ]; + } +} \ No newline at end of file From eb112b8a8590f6bc5bd329752977d7aa843cce67 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 10:33:49 +0200 Subject: [PATCH 08/17] exports: remove duplicate test cfr commit 18a6a5a7ebeefc5999d16f7a3edf9bf89ba8e9e8 --- .../ACPFilters/ActivityTypeFilterTest.php | 2 +- .../config/services/export.yaml | 4 +- .../ActivityTypeFilterTest.php | 80 ------------------- 3 files changed, 3 insertions(+), 83 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilterTest.php diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php index 1be583bb6..10f16247e 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Filter/ACPFilters/ActivityTypeFilterTest.php @@ -37,7 +37,7 @@ final class ActivityTypeFilterTest extends AbstractFilterTest $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); $request->getLocale()->willReturn('fr'); - $this->filter = self::$container->get('chill.person.export.filter_activitytype'); + $this->filter = self::$container->get('chill.activity.export.filter_activitytype'); } public function getFilter() diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index 9abf33487..bdaae8c8a 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -67,10 +67,10 @@ services: name: chill.export_filter alias: 'activity_person_having_ac_bw_date_filter' - chill.person.export.filter_activitytype: + chill.activity.export.filter_activitytype: class: Chill\ActivityBundle\Export\Filter\ACPFilters\ActivityTypeFilter tags: - - { name: chill.export_filter, alias: accompanyingcourse_activitytype_filter } + - { name: chill.export_filter, alias: 'accompanyingcourse_activitytype_filter' } chill.activity.export.locationtype_filter: class: Chill\ActivityBundle\Export\Filter\ACPFilters\LocationTypeFilter diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilterTest.php deleted file mode 100644 index bce092b6e..000000000 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/AccompanyingCourseFilters/ActivityTypeFilterTest.php +++ /dev/null @@ -1,80 +0,0 @@ -prophesize(); - - $request->willExtend(Request::class); - $request->getLocale()->willReturn('fr'); - - $this->filter = self::$container->get('chill.person.export.filter_activitytype'); - } - - public function getFilter() - { - return $this->filter; - } - - public function getFormData(): array - { - $em = self::$container->get(EntityManagerInterface::class); - - $array = $em->createQueryBuilder() - ->from(ActivityType::class, 'at') - ->select('at') - ->getQuery() - ->getResult(); - - $data = []; - - foreach ($array as $t) { - $data[] = ['accepted_activitytypes' => $t]; - } - - return $data; - } - - public function getQueryBuilders(): array - { - if (null === self::$kernel) { - self::bootKernel(); - } - - $em = self::$container->get(EntityManagerInterface::class); - - return [ - $em->createQueryBuilder() - ->from('ChillPersonBundle:AccompanyingPeriod', 'acp') - ->select('acp.id'), - ]; - } -} From 5b3cd9eb2037a26e055020eb0573440219be45c2 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 10:50:12 +0200 Subject: [PATCH 09/17] report export test --- .../Export/Filter/ReportDateFilterTest.php | 69 +++++++++++++++++++ .../config/services/export.yaml | 5 +- 2 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php diff --git a/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php b/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php new file mode 100644 index 000000000..27c107f9d --- /dev/null +++ b/src/Bundle/ChillReportBundle/Tests/Export/Filter/ReportDateFilterTest.php @@ -0,0 +1,69 @@ +prophesize(); + + $request->willExtend(\Symfony\Component\HttpFoundation\Request::class); + $request->getLocale()->willReturn('fr'); + + $this->filter = self::$container->get('chill.report.export.filter_date'); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData(): array + { + return [ + [ + 'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'), + 'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'), + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('r.id') + ->from(Report::class, 'r') + ]; + } +} diff --git a/src/Bundle/ChillReportBundle/config/services/export.yaml b/src/Bundle/ChillReportBundle/config/services/export.yaml index 1ae624118..9650b9e33 100644 --- a/src/Bundle/ChillReportBundle/config/services/export.yaml +++ b/src/Bundle/ChillReportBundle/config/services/export.yaml @@ -8,6 +8,7 @@ services: tags: - { name: chill.export_elements_provider, prefix: 'report' } - Chill\ReportBundle\Export\Filter\ReportDateFilter: + chill.report.export.filter_date: + class: Chill\ReportBundle\Export\Filter\ReportDateFilter tags: - - { name: chill.export_filter, alias: 'report_date' } + - { name: chill.export_filter, alias: 'report_date_filter' } From c059b7700e63e9612ad6aad7a2b11d4e20ac07b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 11:10:35 +0200 Subject: [PATCH 10/17] Improve label for aliases in "Filter by Activity" and use of new-style EntityRepository for ActivityType * [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 --- CHANGELOG.md | 2 + .../Controller/ActivityController.php | 6 +- .../Entity/ActivityType.php | 5 ++ .../Aggregator/ActivityTypeAggregator.php | 6 +- .../Filter/ACPFilters/ActivityTypeFilter.php | 42 ++++++-------- .../Export/Filter/ActivityTypeFilter.php | 34 ++++++----- .../Form/Type/TranslatableActivityType.php | 20 ++----- .../Repository/ActivityTypeRepository.php | 58 ++++++++++++++++--- .../ActivityTypeRepositoryInterface.php | 15 +++++ 9 files changed, 121 insertions(+), 67 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php diff --git a/CHANGELOG.md b/CHANGELOG.md index f4e0ab7f0..1a1fd7210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ 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 ## Test releases diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 2c380ad52..fa6cde7c1 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -17,7 +17,7 @@ use Chill\ActivityBundle\Form\ActivityType; use Chill\ActivityBundle\Repository\ActivityACLAwareRepositoryInterface; use Chill\ActivityBundle\Repository\ActivityRepository; use Chill\ActivityBundle\Repository\ActivityTypeCategoryRepository; -use Chill\ActivityBundle\Repository\ActivityTypeRepository; +use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Repository\LocationRepository; @@ -55,7 +55,7 @@ final class ActivityController extends AbstractController private ActivityTypeCategoryRepository $activityTypeCategoryRepository; - private ActivityTypeRepository $activityTypeRepository; + private ActivityTypeRepositoryInterface $activityTypeRepository; private CenterResolverManagerInterface $centerResolver; @@ -75,7 +75,7 @@ final class ActivityController extends AbstractController public function __construct( ActivityACLAwareRepositoryInterface $activityACLAwareRepository, - ActivityTypeRepository $activityTypeRepository, + ActivityTypeRepositoryInterface $activityTypeRepository, ActivityTypeCategoryRepository $activityTypeCategoryRepository, PersonRepository $personRepository, ThirdPartyRepository $thirdPartyRepository, diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 845b31ca2..a2b15ee23 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -516,6 +516,11 @@ class ActivityType return $this->userVisible; } + public function hasCategory(): bool + { + return null !== $this->getCategory(); + } + /** * Is active * return true if the type is active. diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php index 5c285ca3e..cada50387 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ActivityTypeAggregator.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; -use Chill\ActivityBundle\Repository\ActivityTypeRepository; +use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Closure; @@ -25,12 +25,12 @@ class ActivityTypeAggregator implements AggregatorInterface { public const KEY = 'activity_type_aggregator'; - protected ActivityTypeRepository $activityTypeRepository; + protected ActivityTypeRepositoryInterface $activityTypeRepository; protected TranslatableStringHelperInterface $translatableStringHelper; public function __construct( - ActivityTypeRepository $activityTypeRepository, + ActivityTypeRepositoryInterface $activityTypeRepository, TranslatableStringHelperInterface $translatableStringHelper ) { $this->activityTypeRepository = $activityTypeRepository; diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php index 7c0b202bd..d17a6af99 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ACPFilters/ActivityTypeFilter.php @@ -13,8 +13,9 @@ namespace Chill\ActivityBundle\Export\Filter\ACPFilters; use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\ActivityType; +use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\FilterInterface; -use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\Query\Expr; use Doctrine\ORM\Query\Expr\Andx; @@ -22,15 +23,17 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; -/** - * TODO merge with ActivityTypeFilter in ChillActivity (!?). - */ class ActivityTypeFilter implements FilterInterface { - private TranslatableStringHelper $translatableStringHelper; + private ActivityTypeRepositoryInterface $activityTypeRepository; - public function __construct(TranslatableStringHelper $translatableStringHelper) - { + private TranslatableStringHelperInterface $translatableStringHelper; + + public function __construct( + ActivityTypeRepositoryInterface $activityTypeRepository, + TranslatableStringHelperInterface $translatableStringHelper + ) { + $this->activityTypeRepository = $activityTypeRepository; $this->translatableStringHelper = $translatableStringHelper; } @@ -45,21 +48,10 @@ class ActivityTypeFilter implements FilterInterface $qb->join(Activity::class, 'activity', Expr\Join::WITH, 'activity.accompanyingPeriod = acp'); } - if (!in_array('acttype', $qb->getAllAliases(), true)) { - $qb->join('activity.activityType', 'acttype'); - } + $clause = $qb->expr()->in('activity.activityType', ':selected_activity_types'); - $where = $qb->getDQLPart('where'); - $clause = $qb->expr()->in('acttype.id', ':activitytypes'); - - if ($where instanceof Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); - $qb->setParameter('activitytypes', $data['accepted_activitytypes']); + $qb->andWhere($clause); + $qb->setParameter('selected_activity_types', $data['types']); } public function applyOn() @@ -71,8 +63,12 @@ class ActivityTypeFilter implements FilterInterface { $builder->add('accepted_activitytypes', EntityType::class, [ 'class' => ActivityType::class, + 'choices' => $this->activityTypeRepository->findAllActive(), 'choice_label' => function (ActivityType $aty) { - return $this->translatableStringHelper->localize($aty->getName()); + return + ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()); }, 'multiple' => true, 'expanded' => true, @@ -88,7 +84,7 @@ class ActivityTypeFilter implements FilterInterface } return ['Filtered by activity types: only %activitytypes%', [ - '%activitytypes%' => implode(', ou ', $types), + '%activitytypes%' => implode(', ', $types), ]]; } diff --git a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php index 77d887fdf..7442fabb7 100644 --- a/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php +++ b/src/Bundle/ChillActivityBundle/Export/Filter/ActivityTypeFilter.php @@ -13,7 +13,7 @@ namespace Chill\ActivityBundle\Export\Filter; use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Export\Declarations; -use Chill\ActivityBundle\Repository\ActivityTypeRepository; +use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Export\ExportElementValidatedInterface; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; @@ -28,13 +28,13 @@ use function count; class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInterface { - protected ActivityTypeRepository $activityTypeRepository; + protected ActivityTypeRepositoryInterface $activityTypeRepository; protected TranslatableStringHelperInterface $translatableStringHelper; public function __construct( TranslatableStringHelperInterface $translatableStringHelper, - ActivityTypeRepository $activityTypeRepository + ActivityTypeRepositoryInterface $activityTypeRepository ) { $this->translatableStringHelper = $translatableStringHelper; $this->activityTypeRepository = $activityTypeRepository; @@ -47,16 +47,9 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter public function alterQuery(QueryBuilder $qb, $data) { - $where = $qb->getDQLPart('where'); $clause = $qb->expr()->in('activity.activityType', ':selected_activity_types'); - if ($where instanceof Expr\Andx) { - $where->add($clause); - } else { - $where = $qb->expr()->andX($clause); - } - - $qb->add('where', $where); + $qb->andWhere($clause); $qb->setParameter('selected_activity_types', $data['types']); } @@ -68,11 +61,26 @@ class ActivityTypeFilter implements ExportElementValidatedInterface, FilterInter public function buildForm(FormBuilderInterface $builder) { $builder->add('types', EntityType::class, [ + 'choices' => $this->activityTypeRepository->findAllActive(), 'class' => ActivityType::class, - 'choice_label' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getName()), - 'group_by' => fn (ActivityType $type) => $this->translatableStringHelper->localize($type->getCategory()->getName()), + 'choice_label' => function (ActivityType $aty) { + return + ($aty->hasCategory() ? $this->translatableStringHelper->localize($aty->getCategory()->getName()) . ' > ' : '') + . + $this->translatableStringHelper->localize($aty->getName()); + }, + 'group_by' => function (ActivityType $type) { + if (!$type->hasCategory()) { + return null; + } + + return $this->translatableStringHelper->localize($type->getCategory()->getName()); + }, 'multiple' => true, 'expanded' => false, + 'attr' => [ + 'class' => 'select2' + ] ]); } diff --git a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php index dc6328709..8140043a4 100644 --- a/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/Type/TranslatableActivityType.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Form\Type; use Chill\ActivityBundle\Entity\ActivityType; -use Chill\ActivityBundle\Repository\ActivityTypeRepository; +use Chill\ActivityBundle\Repository\ActivityTypeRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelperInterface; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\QueryBuilder; @@ -23,37 +23,25 @@ use Symfony\Component\OptionsResolver\OptionsResolver; class TranslatableActivityType extends AbstractType { - protected ActivityTypeRepository $activityTypeRepository; + protected ActivityTypeRepositoryInterface $activityTypeRepository; protected TranslatableStringHelperInterface $translatableStringHelper; public function __construct( TranslatableStringHelperInterface $helper, - ActivityTypeRepository $activityTypeRepository + ActivityTypeRepositoryInterface $activityTypeRepository ) { $this->translatableStringHelper = $helper; $this->activityTypeRepository = $activityTypeRepository; } - public function buildForm(FormBuilderInterface $builder, array $options) - { - /** @var QueryBuilder $qb */ - $qb = $options['query_builder']; - - if (true === $options['active_only']) { - $qb->where($qb->expr()->eq('at.active', ':active')); - $qb->setParameter('active', true, Types::BOOLEAN); - } - } - public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults( [ 'class' => ActivityType::class, 'active_only' => true, - 'query_builder' => $this->activityTypeRepository - ->createQueryBuilder('at'), + 'choices' => $this->activityTypeRepository->findAllActive(), 'choice_label' => function (ActivityType $type) { return $this->translatableStringHelper->localize($type->getName()); }, diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php index 735b70054..aee3706cf 100644 --- a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepository.php @@ -13,18 +13,58 @@ namespace Chill\ActivityBundle\Repository; use Chill\ActivityBundle\Entity\ActivityType; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\EntityRepository; use Doctrine\Persistence\ManagerRegistry; +use UnexpectedValueException; -/** - * @method ActivityType|null find($id, $lockMode = null, $lockVersion = null) - * @method ActivityType|null findOneBy(array $criteria, array $orderBy = null) - * @method ActivityType[] findAll() - * @method ActivityType[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) - */ -class ActivityTypeRepository extends ServiceEntityRepository +final class ActivityTypeRepository implements ActivityTypeRepositoryInterface { - public function __construct(ManagerRegistry $registry) + private EntityRepository $repository; + + public function __construct(EntityManagerInterface $em) { - parent::__construct($registry, ActivityType::class); + $this->repository = $em->getRepository(ActivityType::class); } + + /** + * @return array|ActivityType[] + */ + public function findAllActive(): array + { + return $this->findBy(['active' => true]); + } + + public function find($id): ?ActivityType + { + return $this->repository->find($id); + } + + /** + * @return array|ActivityType[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return array|ActivityType[] + */ + public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria): ?ActivityType + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName(): string + { + return ActivityType::class; + } + + } diff --git a/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php new file mode 100644 index 000000000..533798e5e --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Repository/ActivityTypeRepositoryInterface.php @@ -0,0 +1,15 @@ + Date: Wed, 21 Sep 2022 11:29:08 +0200 Subject: [PATCH 11/17] exports: create new filter tests --- src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php index bef4fd200..8e9761c67 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractFilterTest.php @@ -24,7 +24,6 @@ use function is_string; /** * Helper to test filters. * - * @internal */ abstract class AbstractFilterTest extends KernelTestCase { From 3c8dbe56fc918126c58ce39277b05e480ddd4b82 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 21 Sep 2022 12:20:34 +0200 Subject: [PATCH 12/17] exports: create new aggregator tests + minor corrections in aggregators --- .../ACPAggregators/DateAggregator.php | 9 +-- .../ActivityReasonAggregator.php | 4 +- .../BySocialActionAggregatorTest.php | 59 +++++++++++++++++ .../BySocialIssueAggregatorTest.php | 59 +++++++++++++++++ .../ByThirdpartyAggregatorTest.php | 59 +++++++++++++++++ .../ACPAggregators/ByUserAggregatorTest.php | 59 +++++++++++++++++ .../ACPAggregators/DateAggregatorTest.php | 66 +++++++++++++++++++ .../LocationTypeAggregatorTest.php | 59 +++++++++++++++++ .../UserScopeAggregatorTest.php | 59 +++++++++++++++++ .../ActivityReasonAggregatorTest.php | 65 ++++++++++++++++++ .../Test/Export/AbstractAggregatorTest.php | 1 - .../EvaluationTypeAggregator.php | 2 +- .../MaritalStatusAggregator.php | 1 + .../AdministrativeLocationAggregatorTest.php | 58 ++++++++++++++++ .../ClosingMotiveAggregatorTest.php | 58 ++++++++++++++++ .../ConfidentialAggregatorTest.php | 57 ++++++++++++++++ .../DurationAggregatorTest.php | 57 ++++++++++++++++ .../EmergencyAggregatorTest.php | 57 ++++++++++++++++ .../EvaluationAggregatorTest.php | 59 +++++++++++++++++ .../IntensityAggregatorTest.php | 57 ++++++++++++++++ .../JobAggregatorTest.php | 58 ++++++++++++++++ .../OriginAggregatorTest.php | 58 ++++++++++++++++ .../ReferrerAggregatorTest.php | 58 ++++++++++++++++ .../RequestorAggregatorTest.php | 58 ++++++++++++++++ .../ScopeAggregatorTest.php | 58 ++++++++++++++++ .../SocialActionAggregatorTest.php | 58 ++++++++++++++++ .../SocialIssueAggregatorTest.php | 58 ++++++++++++++++ .../StepAggregatorTest.php | 59 +++++++++++++++++ .../EvaluationTypeAggregatorTest.php | 59 +++++++++++++++++ .../ChildrenNumberAggregatorTest.php | 64 ++++++++++++++++++ .../CompositionAggregatorTest.php | 64 ++++++++++++++++++ .../CountryOfBirthAggregatorTest.php | 59 +++++++++++++++++ .../HouseholdPositionAggregatorTest.php | 63 ++++++++++++++++++ .../MaritalStatusAggregatorTest.php | 58 ++++++++++++++++ .../ActionTypeAggregatorTest.php | 8 ++- .../GoalAggregatorTest.php | 8 ++- .../GoalResultAggregatorTest.php | 60 +++++++++++++++++ .../JobAggregatorTest.php | 59 +++++++++++++++++ .../ReferrerAggregatorTest.php | 8 ++- .../ResultAggregatorTest.php | 8 ++- .../ScopeAggregatorTest.php | 59 +++++++++++++++++ 41 files changed, 1925 insertions(+), 22 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php create mode 100644 src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php index 5603b1b78..5147936c9 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/ACPAggregators/DateAggregator.php @@ -50,18 +50,15 @@ class DateAggregator implements AggregatorInterface switch ($data['frequency']) { case 'month': $fmt = 'MM'; - -break; + break; case 'week': $fmt = 'IW'; - -break; + break; case 'year': $fmt = 'YYYY'; $order = 'DESC'; - -break; // order DESC does not works ! + break; // order DESC does not works ! default: throw new RuntimeException(sprintf("The frequency data '%s' is invalid.", $data['frequency'])); diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php index 9d7cd3116..f82793e71 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/PersonAggregators/ActivityReasonAggregator.php @@ -55,10 +55,10 @@ class ActivityReasonAggregator implements AggregatorInterface, ExportElementVali { // add select element if ('reasons' === $data['level']) { - $elem = 'reasons.id'; + $elem = 'actreasons.id'; $alias = 'activity_reasons_id'; } elseif ('categories' === $data['level']) { - $elem = 'category.id'; + $elem = 'actreasoncat.id'; $alias = 'activity_categories_id'; } else { throw new RuntimeException('The data provided are not recognized.'); diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php new file mode 100644 index 000000000..b4da861e8 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialActionAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.bysocialaction_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.socialActions', 'actsocialaction') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php new file mode 100644 index 000000000..ab447739e --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/BySocialIssueAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.bysocialissue_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.socialIssues', 'actsocialissue') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php new file mode 100644 index 000000000..e65ffec62 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByThirdpartyAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.bythirdparty_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.thirdParties', 'acttparty') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php new file mode 100644 index 000000000..da1f0ecac --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/ByUserAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.byuser_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.users', 'actusers') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php new file mode 100644 index 000000000..f8775b8bf --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/DateAggregatorTest.php @@ -0,0 +1,66 @@ +aggregator = self::$container->get('chill.activity.export.date_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'frequency' => 'month', + ], + [ + 'frequency' => 'week', + ], + [ + 'frequency' => 'year', + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php new file mode 100644 index 000000000..8f8b866bc --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/LocationTypeAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.locationtype_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.location', 'actloc') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php new file mode 100644 index 000000000..3434f1a1c --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/ACPAggregators/UserScopeAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.activity.export.userscope_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.accompanyingPeriod', 'actacp') + ->join('activity.user', 'actuser') + , + ]; + } +} diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php new file mode 100644 index 000000000..6de364ae7 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/PersonAggregators/ActivityReasonAggregatorTest.php @@ -0,0 +1,65 @@ +aggregator = self::$container->get('chill.activity.export.reason_aggregator'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'level' => 'reasons', + ], + [ + 'level' => 'categories', + ] + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(activity.id)') + ->from(Activity::class, 'activity') + ->join('activity.person', 'actperson') + ->innerJoin('activity.reasons', 'actreasons') + ->join('actreasons.category', 'actreasoncat') + , + ]; + } +} diff --git a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php index cf5fe5c31..40792a1c6 100644 --- a/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php +++ b/src/Bundle/ChillMainBundle/Test/Export/AbstractAggregatorTest.php @@ -25,7 +25,6 @@ use function is_string; /** * Helper which creates a set of test for aggregators. * - * @internal */ abstract class AbstractAggregatorTest extends KernelTestCase { diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index b4f5e0071..bf0f48ab4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -39,7 +39,7 @@ class EvaluationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->addSelect('IDENTITY(eval.evaluation) AS evaluationtype_aggregator'); + $qb->addSelect('IDENTITY(workeval.evaluation) AS evaluationtype_aggregator'); $groupBy = $qb->getDQLPart('groupBy'); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php index e799d8dfa..2ed1752b0 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/PersonAggregators/MaritalStatusAggregator.php @@ -59,6 +59,7 @@ final class MaritalStatusAggregator implements AggregatorInterface public function buildForm(FormBuilderInterface $builder) { + // no form } public function getLabels($key, array $values, $data) diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php new file mode 100644 index 000000000..82a879b19 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_administrative_location'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.administrativeLocation', 'acploc') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php new file mode 100644 index 000000000..279b621d4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_closingmotive'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.closingMotive', 'acpmotive') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php new file mode 100644 index 000000000..ab0e3dae3 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregatorTest.php @@ -0,0 +1,57 @@ +aggregator = self::$container->get('chill.person.export.aggregator_confidential'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php new file mode 100644 index 000000000..056c396e0 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregatorTest.php @@ -0,0 +1,57 @@ +aggregator = self::$container->get('chill.person.export.aggregator_duration'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php new file mode 100644 index 000000000..0b8ff2b12 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregatorTest.php @@ -0,0 +1,57 @@ +aggregator = self::$container->get('chill.person.export.aggregator_emergency'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php new file mode 100644 index 000000000..8c67eb649 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_evaluation'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php new file mode 100644 index 000000000..b3da8ea13 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregatorTest.php @@ -0,0 +1,57 @@ +aggregator = self::$container->get('chill.person.export.aggregator_intensity'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php new file mode 100644 index 000000000..8e14ffe4c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_referrer_job'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.job', 'acpjob') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php new file mode 100644 index 000000000..cdd709226 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_origin'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.origin', 'acporigin') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php new file mode 100644 index 000000000..789baa228 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_referrer'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.user', 'acpuser') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php new file mode 100644 index 000000000..f888e2535 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_requestor'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.participations', 'acppart') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php new file mode 100644 index 000000000..05fe5e980 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_referrer_scope'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.scopes', 'acpscope') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php new file mode 100644 index 000000000..cdf27c1a5 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_socialaction'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php new file mode 100644 index 000000000..912a2b7c6 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_socialissue'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.socialIssues', 'acpsocialissue') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php new file mode 100644 index 000000000..ee11eeee4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/StepAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_step'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-01-01'), + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php new file mode 100644 index 000000000..60b8d838c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_evaluationtype'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php new file mode 100644 index 000000000..bef052329 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/ChildrenNumberAggregatorTest.php @@ -0,0 +1,64 @@ +aggregator = self::$container->get('chill.person.export.aggregator_household_childrennumber'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.participations', 'acppart') + ->join('acppart.person', 'partperson') + ->join('partperson.householdParticipations', 'member') + ->join('member.household', 'household') + ->join('household.compositions', 'composition') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php new file mode 100644 index 000000000..fc808c03d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/HouseholdAggregators/CompositionAggregatorTest.php @@ -0,0 +1,64 @@ +aggregator = self::$container->get('chill.person.export.aggregator_household_composition'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.participations', 'acppart') + ->join('acppart.person', 'partperson') + ->join('partperson.householdParticipations', 'member') + ->join('member.household', 'household') + ->join('household.compositions', 'composition') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php new file mode 100644 index 000000000..90596d892 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/CountryOfBirthAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_country_of_birth'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + ['group_by_level' => 'continent'], + ['group_by_level' => 'country',], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(person.id)') + ->from(Person::class, 'person') + ->leftJoin('person.countryOfBirth', 'countryOfBirth') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php new file mode 100644 index 000000000..91a22d05a --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/HouseholdPositionAggregatorTest.php @@ -0,0 +1,63 @@ +aggregator = self::$container->get('chill.person.export.aggregator_household_position'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [ + 'date_position' => \DateTime::createFromFormat('Y-m-d', '2022-07-01') + ], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(person.id)') + ->from(Person::class, 'person') + ->join(HouseholdMember::class, 'householdmember', Expr\Join::WITH, 'householdmember.person = person') + ->join('person.center', 'center') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php new file mode 100644 index 000000000..25ddb602d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/PersonAggregators/MaritalStatusAggregatorTest.php @@ -0,0 +1,58 @@ +aggregator = self::$container->get('chill.person.export.aggregator_marital_status'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(person.id)') + ->from(Person::class, 'person') + ->join('person.maritalStatus', 'personmarital') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php index ab0492d11..ed83c3af7 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator; /** @@ -34,14 +35,14 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest return $this->aggregator; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getQueryBuilders() + public function getQueryBuilders(): array { if (null === self::$kernel) { self::bootKernel(); @@ -53,7 +54,8 @@ final class ActionTypeAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), + ->from(AccompanyingPeriodWork::class, 'acpw') + , ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php index ef5bd5097..979f3c488 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\GoalAggregator; /** @@ -34,14 +35,14 @@ final class GoalAggregatorTest extends AbstractAggregatorTest return $this->aggregator; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getQueryBuilders() + public function getQueryBuilders(): array { if (null === self::$kernel) { self::bootKernel(); @@ -53,7 +54,8 @@ final class GoalAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), + ->from(AccompanyingPeriodWork::class, 'acpw') + , ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php new file mode 100644 index 000000000..37642fa33 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/GoalResultAggregatorTest.php @@ -0,0 +1,60 @@ +aggregator = self::$container->get('chill.person.export.aggregator_goalresult'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.goals', 'goal') + ->join('goal.results', 'goalresult') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php new file mode 100644 index 000000000..c686e66b6 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/JobAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_treatingagent_job'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.referrers', 'acpwuser') + , + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php index 446cf1e37..b8070398a 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ReferrerAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ReferrerAggregator; /** @@ -34,14 +35,14 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest return $this->aggregator; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getQueryBuilders() + public function getQueryBuilders(): array { if (null === self::$kernel) { self::bootKernel(); @@ -53,7 +54,8 @@ final class ReferrerAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), + ->from(AccompanyingPeriodWork::class, 'acpw') + , ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php index a34a16a8a..984e296bc 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ResultAggregatorTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; +use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork; use Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ResultAggregator; /** @@ -34,14 +35,14 @@ final class ResultAggregatorTest extends AbstractAggregatorTest return $this->aggregator; } - public function getFormData() + public function getFormData(): array { return [ [], ]; } - public function getQueryBuilders() + public function getQueryBuilders(): array { if (null === self::$kernel) { self::bootKernel(); @@ -53,7 +54,8 @@ final class ResultAggregatorTest extends AbstractAggregatorTest return [ $em->createQueryBuilder() ->select('count(acpw.id)') - ->from('ChillPersonBundle:AccompanyingPeriodWork', 'acpw'), + ->from(AccompanyingPeriodWork::class, 'acpw') + , ]; } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php new file mode 100644 index 000000000..3cece9ed9 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/ScopeAggregatorTest.php @@ -0,0 +1,59 @@ +aggregator = self::$container->get('chill.person.export.aggregator_treatingagent_scope'); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData(): array + { + return [ + [], + ]; + } + + public function getQueryBuilders(): array + { + if (null === self::$kernel) { + self::bootKernel(); + } + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw') + ->join('acpw.referrers', 'acpwuser') + , + ]; + } +} From 8b6493356584ccb1f30cfaceb0c26b2d7d7427c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 12:08:00 +0200 Subject: [PATCH 13/17] [activity][export]: Fixed: rename the alias for accompanying period, to be suitable for usage with acp filters --- .../Export/Export/LinkedToACP/AvgActivityDuration.php | 2 +- .../Export/Export/LinkedToACP/AvgActivityVisitDuration.php | 2 +- .../Export/Export/LinkedToACP/CountActivity.php | 2 +- .../Export/Export/LinkedToACP/SumActivityDuration.php | 2 +- .../Export/Export/LinkedToACP/SumActivityVisitDuration.php | 2 +- .../Export/Export/LinkedToPerson/CountActivity.php | 4 ++-- .../Export/Export/LinkedToPerson/ListActivity.php | 2 +- .../Export/Export/LinkedToPerson/StatActivityDuration.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php index b2346b8fd..5dae4c0ef 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityDuration.php @@ -84,7 +84,7 @@ class AvgActivityDuration implements ExportInterface, GroupedExportInterface public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'actacp'); + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('AVG(activity.durationTime) as export_avg_activity_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php index 0195992fe..560ae8754 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/AvgActivityVisitDuration.php @@ -84,7 +84,7 @@ class AvgActivityVisitDuration implements ExportInterface, GroupedExportInterfac public function initiateQuery(array $requiredModifiers, array $acl, array $data = []) { $qb = $this->repository->createQueryBuilder('activity') - ->join('activity.accompanyingPeriod', 'actacp'); + ->join('activity.accompanyingPeriod', 'acp'); $qb->select('AVG(activity.travelTime) as export_avg_activity_visit_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index e4202c33a..004c2b14e 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -87,7 +87,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb = $this->repository->createQueryBuilder('activity'); if (!in_array('actacp', $qb->getAllAliases(), true)) { - $qb->join('activity.accompanyingPeriod', 'actacp'); + $qb->join('activity.accompanyingPeriod', 'acp'); } $qb->select('COUNT(activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php index 2e87623ef..021966d90 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityDuration.php @@ -86,7 +86,7 @@ class SumActivityDuration implements ExportInterface, GroupedExportInterface $qb = $this->repository->createQueryBuilder('activity'); if (!in_array('actacp', $qb->getAllAliases(), true)) { - $qb->join('activity.accompanyingPeriod', 'actacp'); + $qb->join('activity.accompanyingPeriod', 'acp'); } $qb->select('SUM(activity.durationTime) as export_sum_activity_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php index 5bb6d542e..d64ac9200 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/SumActivityVisitDuration.php @@ -86,7 +86,7 @@ class SumActivityVisitDuration implements ExportInterface, GroupedExportInterfac $qb = $this->repository->createQueryBuilder('activity'); if (!in_array('actacp', $qb->getAllAliases(), true)) { - $qb->join('activity.accompanyingPeriod', 'actacp'); + $qb->join('activity.accompanyingPeriod', 'acp'); } $qb->select('SUM(activity.travelTime) as export_sum_activity_visit_duration'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php index 9f4d15ec7..f12507df8 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/CountActivity.php @@ -86,8 +86,8 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb = $this->activityRepository->createQueryBuilder('activity'); - if (!in_array('actperson', $qb->getAllAliases(), true)) { - $qb->join('activity.person', 'actperson'); + if (!in_array('person', $qb->getAllAliases(), true)) { + $qb->join('activity.person', 'person'); } $qb->select('COUNT(activity.id) as export_count_activity'); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 17b9bd687..78368b0eb 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -210,7 +210,7 @@ class ListActivity implements ListInterface, GroupedExportInterface $qb ->from('ChillActivityBundle:Activity', 'activity') - ->join('activity.person', 'actperson') + ->join('activity.person', 'person') ->join('actperson.center', 'actcenter') ->andWhere('actcenter IN (:authorized_centers)') ->setParameter('authorized_centers', $centers); diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php index bcb4da05d..9013b4648 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/StatActivityDuration.php @@ -120,7 +120,7 @@ class StatActivityDuration implements ExportInterface, GroupedExportInterface } return $qb->select($select) - ->join('activity.person', 'actperson') + ->join('activity.person', 'person') ->join('actperson.center', 'actcenter') ->where($qb->expr()->in('actcenter', ':centers')) ->setParameter(':centers', $centers); 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 14/17] [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); } From 01fb93e9e0d72fe1b3f80115a51c384ce5599779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 16:13:15 +0200 Subject: [PATCH 15/17] [export][activity] count activities only once if the activity is present multiple times due to JOIN --- .../Export/Export/LinkedToACP/CountActivity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php index 004c2b14e..566ee1ef4 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToACP/CountActivity.php @@ -90,7 +90,7 @@ class CountActivity implements ExportInterface, GroupedExportInterface $qb->join('activity.accompanyingPeriod', 'acp'); } - $qb->select('COUNT(activity.id) as export_count_activity'); + $qb->select('COUNT(DISTINCT activity.id) as export_count_activity'); return $qb; } From ca6fde934b4e7b59bf4b375e1ca5113745fdb4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 16:14:07 +0200 Subject: [PATCH 16/17] [export][person] Fixed: fixed inconsistency in requestor query A condition was not present in a subquery, causing to take all courses into account, not the one concerned by the filter --- .../Filter/AccompanyingCourseFilters/RequestorFilter.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php index c0338b42e..e81cf3114 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/RequestorFilter.php @@ -70,10 +70,6 @@ final class RequestorFilter implements FilterInterface case 'other_person': $expr = $this->em->getExpressionBuilder(); - if (!in_array('acppart', $qb->getAllAliases(), true)) { - $qb->join('acp.participations', 'acppart'); - } - $clause = $expr->andX( $expr->isNotNull('acp.requestorPerson'), $expr->notIn( @@ -85,6 +81,7 @@ final class RequestorFilter implements FilterInterface ->join('acp2.participations', 'acppart2') ->select('identity(acp2.requestorPerson)') ->where($expr->eq('acp2.requestorPerson', 'acppart2.person')) + ->andWhere('acp2.id = acp.id') ->getDQL() ) ); From cf9b9b3c75ea6c4800a203834f4d0cca04c15082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 21 Sep 2022 17:28:36 +0200 Subject: [PATCH 17/17] [person][export] Fixed: use left join for related entities in accompanying course aggregators --- CHANGELOG.md | 1 + .../AdministrativeLocationAggregator.php | 15 +++++-------- .../ClosingMotiveAggregator.php | 22 +++++++------------ .../ConfidentialAggregator.php | 9 +------- .../DurationAggregator.php | 11 ++-------- .../EmergencyAggregator.php | 9 +------- .../EvaluationAggregator.php | 17 ++++++-------- .../IntensityAggregator.php | 9 +------- .../JobAggregator.php | 15 +++++-------- .../OriginAggregator.php | 15 +++++-------- .../ReferrerAggregator.php | 15 +++++-------- .../RequestorAggregator.php | 10 +-------- .../ScopeAggregator.php | 15 +++++-------- .../SocialActionAggregator.php | 16 ++++++-------- .../SocialIssueAggregator.php | 12 +++------- .../StepAggregator.php | 11 +++------- .../EvaluationTypeAggregator.php | 17 ++++++-------- .../ActionTypeAggregator.php | 13 +++++------ .../SocialWorkAggregators/GoalAggregator.php | 21 ++++++++---------- .../SocialWorkAggregators/JobAggregator.php | 17 ++++++-------- .../ReferrerAggregator.php | 15 +++++-------- .../ResultAggregator.php | 17 ++++++-------- .../SocialWorkAggregators/ScopeAggregator.php | 15 +++++-------- .../Export/Export/CountEvaluation.php | 2 +- 24 files changed, 113 insertions(+), 206 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fa9e2bb0..df4dab422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to * [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 +* [person][export] Fixed: use left join for related entities in accompanying course aggregators ## Test releases diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php index 13185c2a2..c0d20e7c7 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/AdministrativeLocationAggregator.php @@ -40,18 +40,11 @@ class AdministrativeLocationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acploc', $qb->getAllAliases(), true)) { - $qb->join('acp.administrativeLocation', 'acploc'); + $qb->leftJoin('acp.administrativeLocation', 'acploc'); } $qb->addSelect('IDENTITY(acp.administrativeLocation) AS location_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('location_aggregator'); - } else { - $qb->groupBy('location_aggregator'); - } + $qb->addGroupBy('location_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ class AdministrativeLocationAggregator implements AggregatorInterface return 'Administrative location'; } + if (null === $value) { + return ''; + } + $l = $this->locationRepository->find($value); return $l->getName() . ' (' . $this->translatableStringHelper->localize($l->getLocationType()->getTitle()) . ')'; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php index 033ba4365..f9923c554 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ClosingMotiveAggregator.php @@ -15,6 +15,7 @@ use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Export\Declarations; +use Chill\PersonBundle\Repository\AccompanyingPeriod\ClosingMotiveRepository; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -26,10 +27,10 @@ class ClosingMotiveAggregator implements AggregatorInterface private TranslatableStringHelper $translatableStringHelper; public function __construct( - EntityManagerInterface $em, + ClosingMotiveRepository $motiveRepository, TranslatableStringHelper $translatableStringHelper ) { - $this->motiveRepository = $em->getRepository(ClosingMotive::class); + $this->motiveRepository = $motiveRepository; $this->translatableStringHelper = $translatableStringHelper; } @@ -40,19 +41,8 @@ class ClosingMotiveAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acpmotive', $qb->getAllAliases(), true)) { - $qb->join('acp.closingMotive', 'acpmotive'); - } - $qb->addSelect('IDENTITY(acp.closingMotive) AS closingmotive_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('closingmotive_aggregator'); - } else { - $qb->groupBy('closingmotive_aggregator'); - } + $qb->addGroupBy('closingmotive_aggregator'); } public function applyOn(): string @@ -72,6 +62,10 @@ class ClosingMotiveAggregator implements AggregatorInterface return 'Closing motive'; } + if (NULL === $value) { + return ''; + } + $cm = $this->motiveRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php index ec9bdd348..a2a4919aa 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ConfidentialAggregator.php @@ -35,14 +35,7 @@ class ConfidentialAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.confidential AS confidential_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('confidential_aggregator'); - } else { - $qb->groupBy('confidential_aggregator'); - } + $qb->addGroupBy('confidential_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php index b43b0ba11..ee54da2af 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/DurationAggregator.php @@ -44,15 +44,8 @@ final class DurationAggregator implements AggregatorInterface // et ajouter une fonction custom qui calcule plus précisément les intervals, comme doctrineum/date-interval // https://packagist.org/packages/doctrineum/date-interval#3.1.0 (mais composer fait un conflit de dépendance) - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('duration_aggregator'); - } else { - $qb->groupBy('duration_aggregator'); - } - - $qb->orderBy('duration_aggregator'); + $qb->addGroupBy('duration_aggregator'); + $qb->addOrderBy('duration_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php index f59491ec5..297faf049 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EmergencyAggregator.php @@ -35,14 +35,7 @@ class EmergencyAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.emergency AS emergency_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('emergency_aggregator'); - } else { - $qb->groupBy('emergency_aggregator'); - } + $qb->addGroupBy('emergency_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php index 120506aae..292303cea 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/EvaluationAggregator.php @@ -41,22 +41,15 @@ final class EvaluationAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpw', $qb->getAllAliases(), true)) { - $qb->join('acp.works', 'acpw'); + $qb->leftJoin('acp.works', 'acpw'); } if (!in_array('workeval', $qb->getAllAliases(), true)) { - $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); + $qb->leftJoin('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); } $qb->addSelect('IDENTITY(workeval.evaluation) AS evaluation_aggregator'); - - $groupby = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('evaluation_aggregator'); - } else { - $qb->groupBy('evaluation_aggregator'); - } + $qb->addGroupBy('evaluation_aggregator'); } public function applyOn(): string @@ -76,6 +69,10 @@ final class EvaluationAggregator implements AggregatorInterface return 'Evaluation'; } + if (null === $value) { + return ''; + } + $e = $this->evaluationRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php index 711f7ec0d..c418ea39f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/IntensityAggregator.php @@ -35,14 +35,7 @@ class IntensityAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.intensity AS intensity_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('intensity_aggregator'); - } else { - $qb->groupBy('intensity_aggregator'); - } + $qb->addGroupBy('intensity_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php index 7634ea37f..0809f7654 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php @@ -40,18 +40,11 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpjob', $qb->getAllAliases(), true)) { - $qb->join('acp.job', 'acpjob'); + $qb->leftJoin('acp.job', 'acpjob'); } $qb->addSelect('IDENTITY(acp.job) AS job_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('job_aggregator'); - } else { - $qb->groupBy('job_aggregator'); - } + $qb->addGroupBy('job_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class JobAggregator implements AggregatorInterface return 'Job'; } + if (null === $value) { + return ''; + } + $j = $this->jobRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php index 925160a2d..c7a178fa3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/OriginAggregator.php @@ -42,18 +42,11 @@ final class OriginAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acporigin', $qb->getAllAliases(), true)) { - $qb->join('acp.origin', 'acporigin'); + $qb->leftJoin('acp.origin', 'acporigin'); } $qb->addSelect('acporigin.id AS origin_aggregator'); - - $groupby = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('origin_aggregator'); - } else { - $qb->groupBy('origin_aggregator'); - } + $qb->addGroupBy('origin_aggregator'); } public function applyOn(): string @@ -73,6 +66,10 @@ final class OriginAggregator implements AggregatorInterface return 'Origin'; } + if (null === $value) { + return ''; + } + $o = $this->repository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php index 22eca6f76..7851fe203 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ReferrerAggregator.php @@ -40,18 +40,11 @@ final class ReferrerAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpuser', $qb->getAllAliases(), true)) { - $qb->join('acp.user', 'acpuser'); + $qb->leftJoin('acp.user', 'acpuser'); } $qb->addSelect('acpuser.id AS referrer_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('referrer_aggregator'); - } else { - $qb->groupBy('referrer_aggregator'); - } + $qb->addGroupBy('referrer_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class ReferrerAggregator implements AggregatorInterface return 'Referrer'; } + if (null === $value) { + return ''; + } + $r = $this->userRepository->find($value); return $this->userRender->renderString($r, []); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php index 80195bdcc..2f716c92a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/RequestorAggregator.php @@ -57,15 +57,7 @@ final class RequestorAggregator implements AggregatorInterface END ) AS requestor_aggregator "); - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('requestor_aggregator'); - } else { - $qb->groupBy('requestor_aggregator'); - } - - // TODO 'order by' does not works ! + $qb->addGroupBy('requestor_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php index 5b2901921..0ff6aa747 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/ScopeAggregator.php @@ -40,18 +40,11 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpscope', $qb->getAllAliases(), true)) { - $qb->join('acp.scopes', 'acpscope'); + $qb->leftJoin('acp.scopes', 'acpscope'); } $qb->addSelect('acpscope.id as scope_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('scope_aggregator'); - } else { - $qb->groupBy('scope_aggregator'); - } + $qb->addGroupBy('scope_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class ScopeAggregator implements AggregatorInterface return 'Scope'; } + if (null === $value) { + return ''; + } + $s = $this->scopeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php index 39ad085e3..dc8d2cfb3 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialActionAggregator.php @@ -41,18 +41,12 @@ final class SocialActionAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpw', $qb->getAllAliases(), true)) { + // here, we will only see accompanying period linked with a socialAction $qb->join('acp.works', 'acpw'); } - $qb->addSelect('IDENTITY(acpw.socialAction) AS socialaction_aggregator'); // DISTINCT ?? - - $groupby = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('socialaction_aggregator'); - } else { - $qb->groupBy('socialaction_aggregator'); - } + $qb->addSelect('IDENTITY(acpw.socialAction) AS socialaction_aggregator'); + $qb->addGroupBy('socialaction_aggregator'); } public function applyOn(): string @@ -72,6 +66,10 @@ final class SocialActionAggregator implements AggregatorInterface return 'Social action'; } + if (null === $value) { + return ''; + } + $sa = $this->actionRepository->find($value); return $this->actionRender->renderString($sa, []); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php index ac5ac94c0..98fdbad0c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/SocialIssueAggregator.php @@ -40,18 +40,12 @@ final class SocialIssueAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpsocialissue', $qb->getAllAliases(), true)) { + // we will see accompanying period linked with social issues $qb->join('acp.socialIssues', 'acpsocialissue'); } - + $qb->addSelect('acpsocialissue.id as socialissue_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('socialissue_aggregator'); - } else { - $qb->groupBy('socialissue_aggregator'); - } + $qb->addGroupBy('socialissue_aggregator'); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php index 5c923fdc2..2a1a3db25 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/StepAggregator.php @@ -41,15 +41,9 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface public function alterQuery(QueryBuilder $qb, $data) { $qb->addSelect('acp.step AS step_aggregator'); + $qb->addGroupBy('step_aggregator'); - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('step_aggregator'); - } else { - $qb->groupBy('step_aggregator'); - } - + /* // add date in where clause $where = $qb->getDQLPart('where'); @@ -69,6 +63,7 @@ final class StepAggregator implements AggregatorInterface //, FilterInterface $qb->add('where', $where); $qb->setParameter('ondate', $data['on_date'], Types::DATE_MUTABLE); + */ } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php index bf0f48ab4..29420d5c9 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/EvaluationTypeAggregator.php @@ -39,15 +39,8 @@ class EvaluationTypeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb->addSelect('IDENTITY(workeval.evaluation) AS evaluationtype_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('evaluationtype_aggregator'); - } else { - $qb->groupBy('evaluationtype_aggregator'); - } + $qb->addSelect('IDENTITY(workeval.evaluation) AS eval_evaluationtype_aggregator'); + $qb->addGroupBy('eval_evaluationtype_aggregator'); } public function applyOn(): string @@ -67,6 +60,10 @@ class EvaluationTypeAggregator implements AggregatorInterface return 'Evaluation type'; } + if (null === $value) { + return ''; + } + $ev = $this->evaluationRepository->find($value); return $this->translatableStringHelper->localize($ev->getTitle()); @@ -75,7 +72,7 @@ class EvaluationTypeAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return ['evaluationtype_aggregator']; + return ['eval_evaluationtype_aggregator']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php index fb64b3e01..37d50bf51 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ActionTypeAggregator.php @@ -44,14 +44,7 @@ final class ActionTypeAggregator implements AggregatorInterface } $qb->addSelect('acpwsocialaction.id as action_type_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('action_type_aggregator'); - } else { - $qb->groupBy('action_type_aggregator'); - } + $qb->addGroupBy('action_type_aggregator'); } public function applyOn() @@ -71,6 +64,10 @@ final class ActionTypeAggregator implements AggregatorInterface return 'Social Action Type'; } + if (null === $value) { + return ''; + } + $sa = $this->socialActionRepository->find($value); return $this->actionRender->renderString($sa, []); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php index bc534c678..0f418a678 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/GoalAggregator.php @@ -38,18 +38,11 @@ final class GoalAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('goal', $qb->getAllAliases(), true)) { - $qb->join('acpw.goals', 'goal'); + $qb->leftJoin('acpw.goals', 'goal'); } - $qb->addSelect('IDENTITY(goal.goal) as goal_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('goal_aggregator'); - } else { - $qb->groupBy('goal_aggregator'); - } + $qb->addSelect('IDENTITY(goal.goal) as acpw_goal_aggregator'); + $qb->addGroupBy('acpw_goal_aggregator'); } public function applyOn(): string @@ -69,8 +62,12 @@ final class GoalAggregator implements AggregatorInterface return 'Goal Type'; } + if (null === $value) { + return ''; + } + $g = $this->goalRepository->find($value); - + return $this->translatableStringHelper->localize( $g->getTitle() ); @@ -79,7 +76,7 @@ final class GoalAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return ['goal_aggregator']; + return ['acpw_goal_aggregator']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php index 4d27aa873..ca2e36d97 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/JobAggregator.php @@ -40,18 +40,11 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpwuser', $qb->getAllAliases(), true)) { - $qb->join('acpw.referrers', 'acpwuser'); + $qb->leftJoin('acpw.referrers', 'acpwuser'); } - $qb->addSelect('IDENTITY(acpwuser.userJob) as job_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('job_aggregator'); - } else { - $qb->groupBy('job_aggregator'); - } + $qb->addSelect('IDENTITY(acpwuser.userJob) as job_aggregator') + ->addGroupBy('job_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class JobAggregator implements AggregatorInterface return 'Job'; } + if (null === $value) { + return ''; + } + $j = $this->jobRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php index 35e1e218d..46ef78035 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ReferrerAggregator.php @@ -40,18 +40,11 @@ final class ReferrerAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpwuser', $qb->getAllAliases(), true)) { - $qb->join('acpw.referrers', 'acpwuser'); + $qb->leftJoin('acpw.referrers', 'acpwuser'); } $qb->addSelect('acpwuser.id AS referrer_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('referrer_aggregator'); - } else { - $qb->groupBy('referrer_aggregator'); - } + $qb->addGroupBy('referrer_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class ReferrerAggregator implements AggregatorInterface return 'Referrer'; } + if (null === $value) { + return ''; + } + $r = $this->userRepository->find($value); return $this->userRender->renderString($r, []); diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php index 8f7ac0624..054b0ab55 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ResultAggregator.php @@ -41,15 +41,8 @@ final class ResultAggregator implements AggregatorInterface $qb->join('acpw.results', 'result'); } - $qb->addSelect('result.id as result_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('result_aggregator'); - } else { - $qb->groupBy('result_aggregator'); - } + $qb->addSelect('result.id AS acpw_result_aggregator'); + $qb->addGroupBy('acpw_result_aggregator'); } public function applyOn(): string @@ -69,6 +62,10 @@ final class ResultAggregator implements AggregatorInterface return 'Result Type'; } + if (null === $value) { + return ''; + } + $r = $this->resultRepository->find($value); return $this->translatableStringHelper->localize( @@ -79,7 +76,7 @@ final class ResultAggregator implements AggregatorInterface public function getQueryKeys($data): array { - return ['result_aggregator']; + return ['acpw_result_aggregator']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php index ee479d503..1cf29d46f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/ScopeAggregator.php @@ -40,18 +40,11 @@ final class ScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { if (!in_array('acpwuser', $qb->getAllAliases(), true)) { - $qb->join('acpw.referrers', 'acpwuser'); + $qb->leftJoin('acpw.referrers', 'acpwuser'); } $qb->addSelect('IDENTITY(acpwuser.mainScope) as scope_aggregator'); - - $groupBy = $qb->getDQLPart('groupBy'); - - if (!empty($groupBy)) { - $qb->addGroupBy('scope_aggregator'); - } else { - $qb->groupBy('scope_aggregator'); - } + $qb->addGroupBy('scope_aggregator'); } public function applyOn(): string @@ -71,6 +64,10 @@ final class ScopeAggregator implements AggregatorInterface return 'Scope'; } + if (null === $value) { + return ''; + } + $s = $this->scopeRepository->find($value); return $this->translatableStringHelper->localize( diff --git a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php index 7178a54c8..634b351cf 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/CountEvaluation.php @@ -98,7 +98,7 @@ class CountEvaluation implements ExportInterface, GroupedExportInterface $qb->join('acpw.accompanyingPeriodWorkEvaluations', 'workeval'); } - $qb->select('COUNT(workeval.id) AS export_result'); + $qb->select('COUNT(DISTINCT workeval.id) AS export_result'); return $qb; }