Feature: [export][evaluation] Adding group by evaluation having end date

This commit is contained in:
Julien Fastré 2022-11-02 16:26:56 +01:00
parent bf5ecd25de
commit 17e8e1964d
3 changed files with 27 additions and 12 deletions

View File

@ -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';
}
}

View File

@ -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 }

View File

@ -628,9 +628,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
@ -1020,6 +1017,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: