exports: add a new GeographicalUnitStat aggregator

This commit is contained in:
Mathieu Jaumotte 2022-08-08 15:24:22 +02:00
parent eedfa60bea
commit 29cc589bf2
3 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,96 @@
<?php
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
final class GeographicalUnitStatAggregator implements AggregatorInterface
{
/*
private EntityRepository $repository;
public function __construct(
EntityManagerInterface $em
) {
$this->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;
}
}

View File

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

View File

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