exports: create new indicator to count evaluations

This commit is contained in:
Mathieu Jaumotte 2022-08-09 16:06:32 +02:00
parent 72a5a6cd27
commit 93d0fbead5
6 changed files with 162 additions and 3 deletions

View File

@ -100,6 +100,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
}
$loader->load('services/exports_accompanying_course.yaml');
$loader->load('services/exports_social_actions.yaml');
$loader->load('services/exports_evaluation.yaml');
}
/**

View File

@ -22,7 +22,9 @@ abstract class Declarations
public const ACP_TYPE = 'accompanying_period';
public const SOCIAL_WORK_ACTION_TYPE = 'social_actions';
public const ACP_SHARED = 'accompanying_period_shared';
public const SOCIAL_WORK_ACTION_TYPE = 'social_actions';
public const EVAL_TYPE = 'evaluation';
}

View File

@ -0,0 +1,135 @@
<?php
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Security\Core\Role\Role;
class CountEvaluation implements ExportInterface, GroupedExportInterface
{
private EntityRepository $evaluationRepository;
public function __construct(
EntityManagerInterface $em
) {
$this->evaluationRepository = $em->getRepository(Evaluation::class);
}
/**
* @inheritDoc
*/
public function buildForm(FormBuilderInterface $builder)
{
// TODO: Implement buildForm() method.
}
/**
* @inheritDoc
*/
public function getTitle(): string
{
return 'Count evaluations';
}
/**
* @inheritDoc
*/
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
/**
* @inheritDoc
*/
public function getDescription(): string
{
return 'Count evaluation by various parameters.';
}
/**
* @inheritDoc
*/
public function getLabels($key, array $values, $data)
{
if ('export_result' !== $key) {
throw new LogicException("the key {$key} is not used by this export");
}
$labels = array_combine($values, $values);
$labels['_header'] = $this->getTitle();
return static function ($value) use ($labels) {
return $labels[$value];
};
}
/**
* @inheritDoc
*/
public function getQueryKeys($data): array
{
return ['export_result'];
}
/**
* @inheritDoc
*/
public function getResult($qb, $data)
{
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
/**
* @inheritDoc
*/
public function getType(): string
{
return Declarations::EVAL_TYPE;
}
/**
* @inheritDoc
*/
public function initiateQuery(array $requiredModifiers, array $acl, array $data = [])
{
$qb = $this->evaluationRepository->createQueryBuilder('eval');
$qb->select('COUNT(eval.id) AS export_result');
return $qb;
}
/**
* @inheritDoc
*/
public function requiredRole()
{
return new Role(AccompanyingPeriodVoter::STATS);
}
/**
* @inheritDoc
*/
public function supportsModifiers(): array
{
return [
Declarations::EVAL_TYPE,
];
}
public function getGroup(): string
{
return 'Exports of evaluations';
}
}

View File

@ -111,7 +111,11 @@ class CountPerson implements ExportInterface, GroupedExportInterface
public function supportsModifiers()
{
return [Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN, Declarations::ACP_SHARED];
return [
Declarations::PERSON_TYPE,
Declarations::PERSON_IMPLIED_IN,
Declarations::ACP_SHARED
];
}
public function getGroup(): string

View File

@ -0,0 +1,13 @@
services:
## Indicators
chill.person.export.count_evaluation:
class: Chill\PersonBundle\Export\Export\CountEvaluation
autowire: true
autoconfigure: true
tags:
- { name: chill.export, alias: count_evaluation }
## Filters
## Aggregators

View File

@ -350,6 +350,10 @@ Exports of social work actions: Exports des actions d'accompangement
Count social work actions: Nombre d'actions d'accompagnement
Count social work actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
Exports of evaluations: Exports des évaluations
Count evaluations: Nombre d'évaluations
Count evaluation by various parameters.: Compte le nombre d'évaluations selon différents filtres.
## filters
Filter by person gender: Filtrer par genre de la personne
Accepted genders: Genres acceptés