mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
exports: add new duration aggregator (wip)
This commit is contained in:
parent
7173e4be4a
commit
2c151c2ec9
@ -0,0 +1,99 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
|
use Chill\PersonBundle\Export\Declarations;
|
||||||
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Les regroupements seront un nombre de mois, arrondi à l'unité la plus proche (donc
|
||||||
|
* - au dela de 15 jours => 1 mois,
|
||||||
|
* - jusqu'à 45 jours => 1 mois,
|
||||||
|
* 15 | 45 | 75
|
||||||
|
* --+----o----+----o----+----
|
||||||
|
* | 30 | 60 |
|
||||||
|
* etc.)
|
||||||
|
*/
|
||||||
|
class DurationAggregator implements AggregatorInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getLabels($key, array $values, $data)
|
||||||
|
{
|
||||||
|
return function ($value): string {
|
||||||
|
switch ($value) {
|
||||||
|
|
||||||
|
case '_header':
|
||||||
|
return 'Duration';
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \LogicException(sprintf('The value %s is not valid', $value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getQueryKeys($data): array
|
||||||
|
{
|
||||||
|
return ['duration_aggregator'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
|
{
|
||||||
|
// no form
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Group by duration';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function addRole()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
|
{
|
||||||
|
$qb
|
||||||
|
->addSelect('(acp.closingDate - acp.openingDate) AS duration_aggregator')
|
||||||
|
;
|
||||||
|
|
||||||
|
$groupBy = $qb->getDQLPart('groupBy');
|
||||||
|
|
||||||
|
if (!empty($groupBy)) {
|
||||||
|
$qb->addGroupBy('duration_aggregator');
|
||||||
|
} else {
|
||||||
|
$qb->groupBy('duration_aggregator');
|
||||||
|
}
|
||||||
|
|
||||||
|
$qb->orderBy('duration_aggregator');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
public function applyOn(): string
|
||||||
|
{
|
||||||
|
return Declarations::ACP_TYPE;
|
||||||
|
}
|
||||||
|
}
|
@ -241,3 +241,10 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: accompanyingcourse_referrer_aggregator }
|
- { name: chill.export_aggregator, alias: accompanyingcourse_referrer_aggregator }
|
||||||
|
|
||||||
|
chill.person.export.aggregator_duration:
|
||||||
|
class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\DurationAggregator
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
tags:
|
||||||
|
- { name: chill.export_aggregator, alias: accompanyingcourse_duration_aggregator }
|
||||||
|
|
||||||
|
@ -569,6 +569,7 @@ Group by composition: Grouper les ménages par composition familiale
|
|||||||
Group by number of children: Grouper les ménages par nombre d'enfants
|
Group by number of children: Grouper les ménages par nombre d'enfants
|
||||||
|
|
||||||
## persons aggregators
|
## persons aggregators
|
||||||
|
Group by duration: Grouper par durée du parcours
|
||||||
Group people by nationality: Grouper les personnes par nationalités
|
Group people by nationality: Grouper les personnes par nationalités
|
||||||
Group by level: Grouper par niveau
|
Group by level: Grouper par niveau
|
||||||
Group by continents: Grouper par continent
|
Group by continents: Grouper par continent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user