From f02168950f62be6d1c944c9eeb0ca5699eb1c7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Feb 2024 10:40:07 +0100 Subject: [PATCH 1/2] Export: group accompanying period by person participating --- .../unreleased/Feature-20240207-103951.yaml | 5 ++ .../PersonParticipatingAggregator.php | 78 +++++++++++++++++++ .../PersonParticipatingAggregatorTest.php | 61 +++++++++++++++ .../services/exports_accompanying_course.yaml | 4 + .../translations/messages.fr.yml | 4 + 5 files changed, 152 insertions(+) create mode 100644 .changes/unreleased/Feature-20240207-103951.yaml create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregatorTest.php diff --git a/.changes/unreleased/Feature-20240207-103951.yaml b/.changes/unreleased/Feature-20240207-103951.yaml new file mode 100644 index 000000000..b0f71b7cf --- /dev/null +++ b/.changes/unreleased/Feature-20240207-103951.yaml @@ -0,0 +1,5 @@ +kind: Feature +body: 'Export: group accompanying period by person participating' +time: 2024-02-07T10:39:51.97331052+01:00 +custom: + Issue: "253" diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregator.php new file mode 100644 index 000000000..632d0402d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregator.php @@ -0,0 +1,78 @@ + $this->labelPersonHelper->getLabel($key, $values, 'export.aggregator.course.by-user.header'), + default => throw new \UnexpectedValueException('key not supported: '.$key), + }; + } + + public function getQueryKeys($data) + { + return [self::KEY]; + } + + public function getTitle() + { + return 'export.aggregator.course.by-user.title'; + } + + public function addRole(): ?string + { + return null; + } + + public function alterQuery(QueryBuilder $qb, $data) + { + $k = self::KEY; + + if (!in_array('acppart', $qb->getAllAliases(), true)) { + $qb->join('acp.participations', 'acppart'); + } + + $qb->addSelect("IDENTITY(acppart.person) AS {$k}") + ->addGroupBy($k); + } + + public function applyOn() + { + return Declarations::ACP_TYPE; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregatorTest.php new file mode 100644 index 000000000..8e9cdaf6d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/PersonParticipatingAggregatorTest.php @@ -0,0 +1,61 @@ +labelPersonHelper = self::$container->get(LabelPersonHelper::class); + } + + public function getAggregator() + { + return new PersonParticipatingAggregator($this->labelPersonHelper); + } + + public function getFormData() + { + return [[]]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp'), + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.participations', 'acppart'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index 4eaaf67b0..c869a4494 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -259,3 +259,7 @@ services: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\ClosingDateAggregator: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_closing_date_aggregator } + + Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\PersonParticipatingAggregator: + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_person_part_aggregator } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 783bc6be0..2b5ce5c97 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1038,6 +1038,10 @@ export: header: Code postal course: + by-user: + title: Grouper les parcours par usager participant + header: Usager participant + by_referrer: Computation date for referrer: Date à laquelle le référent était actif by_user_scope: From 439fecd69f1a66d32deb24a459f9da47860d663f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 7 Feb 2024 13:25:49 +0100 Subject: [PATCH 2/2] fix cs --- .../PersonFilters/WithParticipationBetweenDatesFilter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithParticipationBetweenDatesFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithParticipationBetweenDatesFilter.php index 289af5f07..1df656a00 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithParticipationBetweenDatesFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/PersonFilters/WithParticipationBetweenDatesFilter.php @@ -25,7 +25,8 @@ final readonly class WithParticipationBetweenDatesFilter implements FilterInterf { public function __construct( private RollingDateConverterInterface $rollingDateConverter, - ) {} + ) { + } public function addRole(): ?string {