From 4ca10ce38d11f991a0d80e7d264253fbe2374097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 2 Nov 2022 16:26:56 +0100 Subject: [PATCH] Feature: [export][evaluation] Adding group by evaluation having end date --- .../HavingEndDateAggregator.php | 23 +++++++++++-------- .../config/services/exports_evaluation.yaml | 7 ++++++ .../translations/messages.fr.yml | 9 +++++--- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php index af801b74d..e33bb326f 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/EvaluationAggregators/HavingEndDateAggregator.php @@ -16,9 +16,17 @@ use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use LogicException; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class HavingEndDateAggregator implements AggregatorInterface { + private TranslatorInterface $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + public function addRole(): ?string { return null; @@ -27,10 +35,7 @@ class HavingEndDateAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { $qb - ->addSelect(' - CASE true WHEN workeval.endDAte IS NULL ELSE false END - AS eval_enddate_aggregator - ') + ->addSelect('CASE WHEN workeval.endDate IS NULL THEN true ELSE false END AS eval_enddate_aggregator') ->addGroupBy('eval_enddate_aggregator'); } @@ -46,17 +51,17 @@ class HavingEndDateAggregator implements AggregatorInterface public function getLabels($key, array $values, $data) { - return static function ($value): string { + return function ($value): string { if ('_header' === $value) { - return ''; + return 'export.aggregator.eval.by_end_date.Has end date ?'; } switch ($value) { case true: - return 'enddate is specified'; + return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is specified'); case false: - return 'enddate is not specified'; + return $this->translator->trans('export.aggregator.eval.by_end_date.enddate is not specified'); default: throw new LogicException(sprintf('The value %s is not valid', $value)); @@ -71,6 +76,6 @@ class HavingEndDateAggregator implements AggregatorInterface public function getTitle(): string { - return 'Group evaluations having end date'; + return 'export.aggregator.eval.by_end_date.Group evaluations having end date'; } } diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml index a389c1f80..f58b7112b 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_evaluation.yaml @@ -73,3 +73,10 @@ services: autoconfigure: true tags: - { name: chill.export_aggregator, alias: evaluation_bymaxdate_aggregator } + + Chill\PersonBundle\Export\Aggregator\EvaluationAggregators\HavingEndDateAggregator: + autowire: true + autoconfigure: true + tags: + - { name: chill.export_aggregator, alias: evaluation_byend_date_aggregator } + diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 3764325af..89808d900 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -626,9 +626,6 @@ maxdate is specified: la date d'échéance est spécifiée maxdate is not specified: la date d'échéance n'est pas spécifiée "Filtered by maxdate: only %choice%": "Filtré par date d'échéance: uniquement si %choice%" -Group evaluations having end date: Grouper les évaluations qui ont une date de fin -enddate is specified: la date de fin est spécifiée -enddate is not specified: la date de fin n'est pas spécifiée ## household filters/aggr Filter by composition: Filtrer les ménages par composition familiale @@ -1018,6 +1015,12 @@ export: Group by current actions: Grouper les actions en cours Current action: Action en cours Not current action: Action terminée + eval: + by_end_date: + Has end date ?: Évaluation en cours ? + Group evaluations having end date: Grouper les évaluations en cours (avec ou sans date de fin) + enddate is specified: la date de fin est spécifiée + enddate is not specified: la date de fin n'est pas spécifiée filter: course: by_user_scope: