From 29cc589bf2e414d913e1c7eef6af577d6cddf3f1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 8 Aug 2022 15:24:22 +0200 Subject: [PATCH] exports: add a new GeographicalUnitStat aggregator --- .../GeographicalUnitStatAggregator.php | 96 +++++++++++++++++++ .../services/exports_accompanying_course.yaml | 7 ++ .../translations/messages.fr.yml | 2 + 3 files changed, 105 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php new file mode 100644 index 000000000..ed5d80ae8 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/GeographicalUnitStatAggregator.php @@ -0,0 +1,96 @@ +repository = $em->getRepository(...::class); + } + */ + + /** + * @inheritDoc + */ + public function getLabels($key, array $values, $data) + { + return function ($value): string { + if ('_header' === $value) { + return 'Geographical unit'; + } + + $g = $this->repository->find($value); + + return $g; //... + }; + } + + /** + * @inheritDoc + */ + public function getQueryKeys($data): array + { + return ['geographicalunitstat_aggregator']; + } + + /** + * @inheritDoc + */ + public function buildForm(FormBuilderInterface $builder) + { + // TODO: Implement buildForm() method. + } + + /** + * @inheritDoc + */ + public function getTitle(): string + { + return 'Group by geographical unit'; + } + + /** + * @inheritDoc + */ + public function addRole() + { + return null; + } + + /** + * @inheritDoc + */ + public function alterQuery(QueryBuilder $qb, $data) + { + + //$qb->addSelect('... AS geographicalunitstat_aggregator'); + + $groupby = $qb->getDQLPart('groupBy'); + + if (!empty($groupBy)) { + $qb->addGroupBy('geographicalunitstat_aggregator'); + } else { + $qb->groupBy('geographicalunitstat_aggregator'); + } + } + + /** + * @inheritDoc + */ + public function applyOn(): string + { + return Declarations::ACP_TYPE; + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index 1e313d59d..de10f5788 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -178,6 +178,13 @@ services: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_step_aggregator } + chill.person.export.aggregator_geographicalunitstat: + class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\GeographicalUnitStatAggregator + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: accompanyingcourse_geographicalunitstat_aggregator } + chill.person.export.aggregator_socialaction: class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\SocialActionAggregator autowire: true diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index dc32a2cae..e909f0ab7 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -449,6 +449,8 @@ Step: Statut Group by step: Grouper les parcours par statut du parcours Filter by geographical unit: Filtrer les parcours par zone géographique +Group by geographical unit: Grouper les parcours par zone géographique +Geographical unit: Zone géographique Filter by socialaction: Filtrer les parcours par action d'accompagnement Accepted socialactions: Actions d'accompagnement