start of social actions export

This commit is contained in:
Julie Lenaerts 2022-07-26 10:41:24 +02:00
parent 70f118011b
commit a06a2c9592
5 changed files with 132 additions and 10 deletions

View File

@ -21,4 +21,6 @@ abstract class Declarations
public const PERSON_TYPE = 'person';
public const ACP_TYPE = 'accompanying_period';
public const SOCIAL_ACTION_TYPE = 'social_actions';
}

View File

@ -0,0 +1,107 @@
<?php
/**
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Chill\PersonBundle\Export\Export;
use Chill\MainBundle\Export\ExportInterface;
use Chill\MainBundle\Export\FormatterInterface;
use Chill\MainBundle\Export\GroupedExportInterface;
use Chill\PersonBundle\Export\Declarations;
use Chill\PersonBundle\Repository\SocialWork\SocialActionRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use LogicException;
class CountSocialAction implements ExportInterface, GroupedExportInterface
{
protected SocialActionRepository $socialActionRepository;
public function __construct(SocialActionRepository $socialActionRepository)
{
$this->socialActionRepository = $socialActionRepository;
}
public function buildForm(FormBuilderInterface $builder): void
{
// TODO: Implement buildForm() method.
}
public function getTitle(): string
{
return 'Count social actions';
}
public function getAllowedFormattersTypes(): array
{
return [FormatterInterface::TYPE_TABULAR];
}
public function getDescription(): string
{
return 'Count social actions by various parameters';
}
public function getLabels($key, array $values, $data)
{
if ('export_count_social_actions' !== $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];
};
}
public function getQueryKeys($data): array
{
return ['export_count_social_actions'];
}
public function getResult($qb, $data)
{
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
}
public function getType(): string
{
return Declarations::SOCIAL_ACTION_TYPE;
}
public function initiateQuery(array $requiredModifiers, array $acl, array $data = []): QueryBuilder
{
$qb = $this
->socialActionRepository
->createQueryBuilder('sa')
->select('COUNT(sa.id) as export_count_social_actions');
return $qb;
}
public function requiredRole(): string
{
return AccompanyingPeriodVoter::STATS;
}
public function supportsModifiers(): array
{
return [Declarations::SOCIAL_ACTION_TYPE];
}
public function getGroup(): string
{
return 'Exports of social actions';
}
}

View File

@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Repository\SocialWork;
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
final class SocialActionRepository implements ObjectRepository
@ -25,6 +26,11 @@ final class SocialActionRepository implements ObjectRepository
$this->repository = $entityManager->getRepository(SocialAction::class);
}
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
{
return $this->repository->createQueryBuilder($alias, $indexBy);
}
public function find($id, ?int $lockMode = null, ?int $lockVersion = null): ?SocialAction
{
return $this->repository->find($id, $lockMode, $lockVersion);

View File

@ -27,18 +27,23 @@ services:
- { name: chill.export, alias: list_person_duplicate }
chill.person.export.count_accompanyingcourse:
class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: chill.export, alias: count_accompanyingcourse }
class: Chill\PersonBundle\Export\Export\CountAccompanyingCourse
arguments:
- "@doctrine.orm.entity_manager"
tags:
- { name: chill.export, alias: count_accompanyingcourse }
chill.person.export.avg_accompanyingcourse_duration:
class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration
arguments:
- '@Chill\PersonBundle\Repository\AccompanyingPeriodRepository'
tags:
- { name: chill.export, alias: avg_accompanyingcourse_duration }
class: Chill\PersonBundle\Export\Export\StatAccompanyingCourseDuration
arguments:
- '@Chill\PersonBundle\Repository\AccompanyingPeriodRepository'
tags:
- { name: chill.export, alias: avg_accompanyingcourse_duration }
chill.person.export.count_social_actions:
class: Chill\PersonBundle\Export\Export\CountSocialActions
autowire: true
autoconfigure: true
chill.person.export.filter_gender:
class: Chill\PersonBundle\Export\Filter\GenderFilter

View File

@ -340,7 +340,9 @@ Create a list of duplicate people: Créer la liste des personnes détectées com
Exports of accompanying courses: Exports des parcours d'accompagnement
Count accompanying courses: Nombre de parcours
Count social actions: Nombre d'actions d'accompagnement
Count accompanying courses by various parameters: Compte le nombre de parcours en fonction de différents filtres.
Count social actions by various parameters: Compte le nombre d'actions d'accompagnement en fonction de différents filtres.
Accompanying courses duration: Durée moyenne des parcours
Create an average of accompanying courses duration according to various filters: Moyenne de la durée des parcours en jours, selon différents filtres.
Closingdate to apply: Date de fin à prendre en compte lorsque le parcours n'est pas clotûré