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

This commit is contained in:
2022-11-02 16:26:56 +01:00
parent f0b2ec1348
commit 4ca10ce38d
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';
}
}