From 694477386824e6999bb3572f51a65bc90b63bc05 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 13 Nov 2023 17:53:02 +0100 Subject: [PATCH 01/12] create 6 new filters/aggr files --- .../CreatorAggregator.php | 69 ++++++++++++++ .../CreatorJobAggregator.php | 69 ++++++++++++++ .../CreatorScopeAggregator.php | 69 ++++++++++++++ .../SocialWorkFilters/CreatorFilter.php | 85 +++++++++++++++++ .../SocialWorkFilters/CreatorJobFilter.php | 91 +++++++++++++++++++ .../SocialWorkFilters/CreatorScopeFilter.php | 91 +++++++++++++++++++ .../services/exports_social_actions.yaml | 25 +++++ .../translations/messages.fr.yml | 17 ++++ 8 files changed, 516 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php create mode 100644 src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php new file mode 100644 index 000000000..afe416f9f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php @@ -0,0 +1,69 @@ +add(); + } + + public function getFormDefaultData(): array + { + return []; + } + + public function getLabels($key, array $values, mixed $data) + { + return function ($value): string { + + }; + } + + public function getQueryKeys($data): array + { + return []; + } + + public function getTitle(): string + { + return 'export.aggregator.course_work.by_creator.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php new file mode 100644 index 000000000..ea53c4f80 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php @@ -0,0 +1,69 @@ +add(); + } + + public function getFormDefaultData(): array + { + return []; + } + + public function getLabels($key, array $values, mixed $data) + { + return function ($value): string { + + }; + } + + public function getQueryKeys($data): array + { + return []; + } + + public function getTitle(): string + { + return 'export.aggregator.course_work.by_creator_job.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php new file mode 100644 index 000000000..e8eab62d4 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php @@ -0,0 +1,69 @@ +add(); + } + + public function getFormDefaultData(): array + { + return []; + } + + public function getLabels($key, array $values, mixed $data) + { + return function ($value): string { + + }; + } + + public function getQueryKeys($data): array + { + return []; + } + + public function getTitle(): string + { + return 'export.aggregator.course_work.by_creator_scope.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php new file mode 100644 index 000000000..791b521af --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php @@ -0,0 +1,85 @@ +join('acpw.createdBy', "{$p}_creator") + ->andWhere($qb->expr()->in("{$p}_creator", ":{$p}_creators")) + ->setParameter("{$p}_creators", $data['creators']) + //->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert( + // $data['creator_at'] ?? new RollingDate(RollingDate::T_TODAY) + //)) + ; + + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('creators', PickUserDynamicType::class, [ + 'multiple' => true, + 'label' => 'export.filter.work.by_creator.Creators', + ]) + //->add('creator_at', PickRollingDateType::class, [ + // 'label' => 'export.filter.work.by_creator.Calc date', + // 'help' => 'export.filter.work.by_creator.calc_date_help', + //]) + ; + } + + public function describeAction($data, $format = 'string'): array + { + return []; + } + + public function getFormDefaultData(): array + { + return [ + 'creators' => [], + //'creator_at' => new RollingDate(RollingDate::T_TODAY), + ]; + } + + public function getTitle(): string + { + return 'export.filter.work.by_creator.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php new file mode 100644 index 000000000..28d31920d --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php @@ -0,0 +1,91 @@ +setParameter("{$p}_jobs", $data['jobs']) + ; + + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('jobs', EntityType::class, [ + 'class' => UserJob::class, + 'choices' => $this->userJobRepository->findAllActive(), + 'multiple' => true, + 'expanded' => true, + 'choice_label' => fn (UserJob $job) => $this->translatableStringHelper->localize($job->getLabel()), + 'label' => 'Job', + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $creatorJobs = []; + + foreach ($data['jobs'] as $j) { + $creatorJobs[] = $this->translatableStringHelper->localize( + $j->getLabel() + ); + } + + return ['export.filter.work.by_creator_job.Filtered by creator job: only %jobs%', [ + '%jobs%' => implode(', ', $creatorJobs), + ]]; + } + + public function getFormDefaultData(): array + { + return [ + 'jobs' => [], + ]; + } + + public function getTitle(): string + { + return 'export.filter.work.by_creator_job.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php new file mode 100644 index 000000000..f21bf320e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php @@ -0,0 +1,91 @@ +setParameter("{$p}_scopes", $data['scopes']) + ; + + } + + public function applyOn(): string + { + return Declarations::SOCIAL_WORK_ACTION_TYPE; + } + + public function buildForm(FormBuilderInterface $builder) + { + $builder + ->add('scopes', EntityType::class, [ + 'class' => Scope::class, + 'choices' => $this->scopeRepository->findAllActive(), + 'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()), + 'multiple' => true, + 'expanded' => true, + 'label' => 'Scope', + ]); + } + + public function describeAction($data, $format = 'string'): array + { + $creatorScopes = []; + + foreach ($data['scopes'] as $s) { + $creatorScopes[] = $this->translatableStringHelper->localize( + $s->getName() + ); + } + + return ['export.filter.work.by_creator_scope.Filtered by creator scope: only %scopes%', [ + '%scopes%' => implode(', ', $creatorScopes), + ]]; + } + + public function getFormDefaultData(): array + { + return [ + 'scopes' => [], + ]; + } + + public function getTitle(): string + { + return 'export.filter.work.by_creator_scope.title'; + } +} diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index 3e6f12fe1..7bdf0345b 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -63,6 +63,19 @@ services: tags: - { name: chill.export_filter, alias: social_work_actions_end_btw_dates_filter } + Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorFilter: + tags: + - { name: chill.export_filter, alias: social_work_actions_creator_filter } + + Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorJobFilter: + tags: + - { name: chill.export_filter, alias: social_work_actions_creator_job_filter } + + Chill\PersonBundle\Export\Filter\SocialWorkFilters\CreatorScopeFilter: + tags: + - { name: chill.export_filter, alias: social_work_actions_creator_scope_filter } + + ## AGGREGATORS chill.person.export.aggregator_action_type: class: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\ActionTypeAggregator @@ -105,6 +118,18 @@ services: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_handling3party_aggregator } +# +# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorAggregator: +# tags: +# - { name: chill.export_aggregator, alias: social_work_actions_creator_aggregator } +# +# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorJobAggregator: +# tags: +# - { name: chill.export_aggregator, alias: social_work_actions_creator_job_aggregator } +# +# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorScopeAggregator: +# tags: +# - { name: chill.export_aggregator, alias: social_work_actions_creator_scope_aggregator } Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HandlingThirdPartyFilter: tags: diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 71b428920..6ee525f8b 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1094,6 +1094,12 @@ export: by_handling_third_party: title: Grouper les actions par tiers traitant header: Tiers traitant + by_creator: + title: Grouper les actions par créateur + by_creator_job: + title: Grouper les actions par métier du créateur + by_creator_scope: + title: Grouper les actions par service du créateur eval: by_end_date: @@ -1214,6 +1220,17 @@ export: title: Filtrer les actions par tiers traitant Only 3 parties %3parties%: "Seulement les actions d'accompagnement qui ont pour tiers traitant: %3parties%" pick_3parties: Tiers traitants des actions + by_creator: + title: Filtrer les actions par créateur + Creators: Créateur de l'action + #Calc date: Date à laquelle le créateur ... + #calc_date_help: Il s'agit de la date à laquelle le créateur ... + by_creator_job: + title: Filtrer les actions par métier du créateur + "Filtered by creator job: only %jobs%'": "Filtré par métier du créateur: uniquement %jobs%" + by_creator_scope: + title: Filtrer les actions par service du créateur + "Filtered by creator scope: only %scopes%'": "Filtré par service du créateur: uniquement %scopes%" list: person_with_acp: From 3892d1e8770566abf84209b0fd80c1f356fe1090 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 13:21:33 +0100 Subject: [PATCH 02/12] remove date field --- .../SocialWorkFilters/CreatorFilter.php | 27 +++++++------------ .../translations/messages.fr.yml | 1 + 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php index 791b521af..1907edb57 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php @@ -11,9 +11,9 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Form\Type\PickUserDynamicType; -use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,9 +22,7 @@ class CreatorFilter implements FilterInterface { private const PREFIX = 'acpw_filter_creator'; - public function __construct( - private readonly TranslatableStringHelper $translatableStringHelper - ) {} + public function __construct() {} public function addRole(): ?string { @@ -38,12 +36,7 @@ class CreatorFilter implements FilterInterface $qb ->join('acpw.createdBy', "{$p}_creator") ->andWhere($qb->expr()->in("{$p}_creator", ":{$p}_creators")) - ->setParameter("{$p}_creators", $data['creators']) - //->setParameter("{$p}_calc_date", $this->rollingDateConverter->convert( - // $data['creator_at'] ?? new RollingDate(RollingDate::T_TODAY) - //)) - ; - + ->setParameter("{$p}_creators", $data['creators']); } public function applyOn(): string @@ -57,24 +50,22 @@ class CreatorFilter implements FilterInterface ->add('creators', PickUserDynamicType::class, [ 'multiple' => true, 'label' => 'export.filter.work.by_creator.Creators', - ]) - //->add('creator_at', PickRollingDateType::class, [ - // 'label' => 'export.filter.work.by_creator.Calc date', - // 'help' => 'export.filter.work.by_creator.calc_date_help', - //]) - ; + ]); } public function describeAction($data, $format = 'string'): array { - return []; + return [ + 'export.filter.work.by_creator.Filtered by creator: only %creators%', [ + '%creators%' => implode(', ', array_map(static fn (User $u) => $u->getLabel(), $data['creators'])), + ], + ]; } public function getFormDefaultData(): array { return [ 'creators' => [], - //'creator_at' => new RollingDate(RollingDate::T_TODAY), ]; } diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 6ee525f8b..878ff7970 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1223,6 +1223,7 @@ export: by_creator: title: Filtrer les actions par créateur Creators: Créateur de l'action + "Filtered by creator: only %creators%": "Filtré par créateur de l'action: uniquement %creators%" #Calc date: Date à laquelle le créateur ... #calc_date_help: Il s'agit de la date à laquelle le créateur ... by_creator_job: From fde6000d0b05e8bcebe0ed951bbd2c0fdcc2a296 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 13:43:28 +0100 Subject: [PATCH 03/12] filters alterQuery --- .../SocialWorkFilters/CreatorFilter.php | 4 +--- .../SocialWorkFilters/CreatorJobFilter.php | 22 ++++++++++++++++--- .../SocialWorkFilters/CreatorScopeFilter.php | 22 ++++++++++++++++--- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php index 1907edb57..100bcfdc4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorFilter.php @@ -22,8 +22,6 @@ class CreatorFilter implements FilterInterface { private const PREFIX = 'acpw_filter_creator'; - public function __construct() {} - public function addRole(): ?string { return null; @@ -34,7 +32,7 @@ class CreatorFilter implements FilterInterface $p = self::PREFIX; $qb - ->join('acpw.createdBy', "{$p}_creator") + ->leftJoin('acpw.createdBy', "{$p}_creator") ->andWhere($qb->expr()->in("{$p}_creator", ":{$p}_creators")) ->setParameter("{$p}_creators", $data['creators']); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php index 28d31920d..47b5f4c9c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php @@ -11,11 +11,13 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters; +use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Repository\UserJobRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -39,9 +41,23 @@ class CreatorJobFilter implements FilterInterface $p = self::PREFIX; $qb - ->setParameter("{$p}_jobs", $data['jobs']) - ; - + ->leftJoin( + UserJobHistory::class, + "{$p}_history", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_history.endDate"), + $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + ) + ) + ) + ) + ->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs")) + ->setParameter("{$p}_jobs", $data['jobs']); } public function applyOn(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php index f21bf320e..996aa5272 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php @@ -12,10 +12,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters; use Chill\MainBundle\Entity\Scope; +use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\FilterInterface; use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\FormBuilderInterface; @@ -39,9 +41,23 @@ class CreatorScopeFilter implements FilterInterface $p = self::PREFIX; $qb - ->setParameter("{$p}_scopes", $data['scopes']) - ; - + ->leftJoin( + UserScopeHistory::class, + "{$p}_history", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_history.endDate"), + $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + ) + ) + ) + ) + ->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scopes")) + ->setParameter("{$p}_scopes", $data['scopes']); } public function applyOn(): string From b790e2fcf199482faed7710fcae2f19197d0e703 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 14:18:50 +0100 Subject: [PATCH 04/12] complete aggregators --- .../CreatorAggregator.php | 29 +++++++++---- .../CreatorJobAggregator.php | 42 ++++++++++++++++--- .../CreatorScopeAggregator.php | 42 ++++++++++++++++--- .../translations/messages.fr.yml | 5 ++- 4 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php index afe416f9f..9d03e3ba1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php @@ -12,7 +12,8 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Templating\TranslatableStringHelper; +use Chill\MainBundle\Repository\UserRepository; +use Chill\MainBundle\Templating\Entity\UserRender; use Chill\PersonBundle\Export\Declarations; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,7 +23,8 @@ class CreatorAggregator implements AggregatorInterface private const PREFIX = 'acpw_aggr_creator'; public function __construct( - private readonly TranslatableStringHelper $translatableStringHelper + private UserRepository $userRepository, + private UserRender $userRender ) {} public function addRole(): ?string @@ -32,7 +34,11 @@ class CreatorAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb; + $p = self::PREFIX; + + $qb + ->addSelect("IDENTITY(acpw.createdBy) AS {$p}_select") + ->addGroupBy("{$p}_select"); } public function applyOn(): string @@ -40,10 +46,7 @@ class CreatorAggregator implements AggregatorInterface return Declarations::SOCIAL_WORK_ACTION_TYPE; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add(); - } + public function buildForm(FormBuilderInterface $builder) {} public function getFormDefaultData(): array { @@ -53,13 +56,23 @@ class CreatorAggregator implements AggregatorInterface public function getLabels($key, array $values, mixed $data) { return function ($value): string { + if ('_header' === $value) { + return 'export.aggregator.course_work.by_creator.Creator'; + }; + if (null === $value || '' === $value) { + return ''; + } + + $r = $this->userRepository->find($value); + + return $this->userRender->renderString($r, ['absence' => false, 'user_job' => false, 'main_scope' => false]); }; } public function getQueryKeys($data): array { - return []; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php index ea53c4f80..fd5444b62 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php @@ -11,9 +11,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators; +use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; +use Chill\MainBundle\Repository\UserJobRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,6 +25,7 @@ class CreatorJobAggregator implements AggregatorInterface private const PREFIX = 'acpw_aggr_creator_job'; public function __construct( + private readonly UserJobRepository $jobRepository, private readonly TranslatableStringHelper $translatableStringHelper ) {} @@ -32,7 +36,26 @@ class CreatorJobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb; + $p = self::PREFIX; + + $qb + ->leftJoin( + UserJobHistory::class, + "{$p}_history", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_history.endDate"), + $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + ) + ) + ) + ) + ->addSelect("IDENTITY({$p}_history.job) AS {$p}_select") + ->addGroupBy("{$p}_select"); } public function applyOn(): string @@ -40,10 +63,7 @@ class CreatorJobAggregator implements AggregatorInterface return Declarations::SOCIAL_WORK_ACTION_TYPE; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add(); - } + public function buildForm(FormBuilderInterface $builder) {} public function getFormDefaultData(): array { @@ -53,13 +73,23 @@ class CreatorJobAggregator implements AggregatorInterface public function getLabels($key, array $values, mixed $data) { return function ($value): string { + if ('_header' === $value) { + return 'export.aggregator.course_work.by_creator_job.Creator\'s job'; + } + if (null === $value || '' === $value || null === $j = $this->jobRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize( + $j->getLabel() + ); }; } public function getQueryKeys($data): array { - return []; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php index e8eab62d4..fdbbf56a4 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php @@ -11,9 +11,12 @@ declare(strict_types=1); namespace Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators; +use Chill\MainBundle\Entity\User\UserScopeHistory; use Chill\MainBundle\Export\AggregatorInterface; +use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Export\Declarations; +use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -22,6 +25,7 @@ class CreatorScopeAggregator implements AggregatorInterface private const PREFIX = 'acpw_aggr_creator_scope'; public function __construct( + private readonly ScopeRepository $scopeRepository, private readonly TranslatableStringHelper $translatableStringHelper ) {} @@ -32,7 +36,26 @@ class CreatorScopeAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - $qb; + $p = self::PREFIX; + + $qb + ->leftJoin( + UserScopeHistory::class, + "{$p}_history", + Join::WITH, + $qb->expr()->andX( + $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->andX( + $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->orX( + $qb->expr()->isNull("{$p}_history.endDate"), + $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + ) + ) + ) + ) + ->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select") + ->addGroupBy("{$p}_select"); } public function applyOn(): string @@ -40,10 +63,7 @@ class CreatorScopeAggregator implements AggregatorInterface return Declarations::SOCIAL_WORK_ACTION_TYPE; } - public function buildForm(FormBuilderInterface $builder) - { - $builder->add(); - } + public function buildForm(FormBuilderInterface $builder) {} public function getFormDefaultData(): array { @@ -53,13 +73,23 @@ class CreatorScopeAggregator implements AggregatorInterface public function getLabels($key, array $values, mixed $data) { return function ($value): string { + if ('_header' === $value) { + return 'export.aggregator.course_work.by_creator_scope.Creator\'s scope'; + } + if (null === $value || '' === $value || null === $s = $this->scopeRepository->find($value)) { + return ''; + } + + return $this->translatableStringHelper->localize( + $s->getName() + ); }; } public function getQueryKeys($data): array { - return []; + return [self::PREFIX.'_select']; } public function getTitle(): string diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 878ff7970..12705cb29 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1096,10 +1096,13 @@ export: header: Tiers traitant by_creator: title: Grouper les actions par créateur + Creator: Créateur de l'action by_creator_job: title: Grouper les actions par métier du créateur + Creator's job: Métier du créateur by_creator_scope: title: Grouper les actions par service du créateur + Creator's scope: Service du créateur eval: by_end_date: @@ -1224,8 +1227,6 @@ export: title: Filtrer les actions par créateur Creators: Créateur de l'action "Filtered by creator: only %creators%": "Filtré par créateur de l'action: uniquement %creators%" - #Calc date: Date à laquelle le créateur ... - #calc_date_help: Il s'agit de la date à laquelle le créateur ... by_creator_job: title: Filtrer les actions par métier du créateur "Filtered by creator job: only %jobs%'": "Filtré par métier du créateur: uniquement %jobs%" From 83c3621c26e68e2118e41a29c8e3b3f6b286f275 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 14:24:05 +0100 Subject: [PATCH 05/12] declare service --- .../services/exports_social_actions.yaml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml index 7bdf0345b..7bb735e48 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_social_actions.yaml @@ -118,18 +118,18 @@ services: Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\HandlingThirdPartyAggregator: tags: - { name: chill.export_aggregator, alias: accompanyingcourse_handling3party_aggregator } -# -# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorAggregator: -# tags: -# - { name: chill.export_aggregator, alias: social_work_actions_creator_aggregator } -# -# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorJobAggregator: -# tags: -# - { name: chill.export_aggregator, alias: social_work_actions_creator_job_aggregator } -# -# Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorScopeAggregator: -# tags: -# - { name: chill.export_aggregator, alias: social_work_actions_creator_scope_aggregator } + + Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorAggregator: + tags: + - { name: chill.export_aggregator, alias: social_work_actions_creator_aggregator } + + Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorJobAggregator: + tags: + - { name: chill.export_aggregator, alias: social_work_actions_creator_job_aggregator } + + Chill\PersonBundle\Export\Aggregator\SocialWorkAggregators\CreatorScopeAggregator: + tags: + - { name: chill.export_aggregator, alias: social_work_actions_creator_scope_aggregator } Chill\PersonBundle\Export\Filter\AccompanyingCourseFilters\HandlingThirdPartyFilter: tags: From 3e39c0ced7ea371dfaba42ad1b0431d8247581a1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 14:33:50 +0100 Subject: [PATCH 06/12] rector and cs-fixer --- .changes/unreleased/Feature-20231114-143558.yaml | 7 +++++++ .../ChillActivityBundle/Controller/ActivityController.php | 4 ++-- .../Aggregator/SocialWorkAggregators/CreatorAggregator.php | 6 +++--- .../SocialWorkAggregators/CreatorJobAggregator.php | 6 +++--- .../SocialWorkAggregators/CreatorScopeAggregator.php | 6 +++--- .../Export/Filter/SocialWorkFilters/CreatorJobFilter.php | 6 +++--- .../Export/Filter/SocialWorkFilters/CreatorScopeFilter.php | 6 +++--- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 2 +- 8 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 .changes/unreleased/Feature-20231114-143558.yaml diff --git a/.changes/unreleased/Feature-20231114-143558.yaml b/.changes/unreleased/Feature-20231114-143558.yaml new file mode 100644 index 000000000..edc72c027 --- /dev/null +++ b/.changes/unreleased/Feature-20231114-143558.yaml @@ -0,0 +1,7 @@ +kind: Feature +body: |+ + Add 3 new filters and 3 new aggregators for work action creator (with jobs and scopes) + +time: 2023-11-14T14:35:58.099418749+01:00 +custom: + Issue: "204" diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 06489010c..43c0b13bb 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -673,8 +673,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php index 9d03e3ba1..f7c203a4e 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorAggregator.php @@ -23,8 +23,8 @@ class CreatorAggregator implements AggregatorInterface private const PREFIX = 'acpw_aggr_creator'; public function __construct( - private UserRepository $userRepository, - private UserRender $userRender + private readonly UserRepository $userRepository, + private readonly UserRender $userRender ) {} public function addRole(): ?string @@ -58,7 +58,7 @@ class CreatorAggregator implements AggregatorInterface return function ($value): string { if ('_header' === $value) { return 'export.aggregator.course_work.by_creator.Creator'; - }; + } if (null === $value || '' === $value) { return ''; diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php index fd5444b62..1f7fdca5a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregator.php @@ -44,12 +44,12 @@ class CreatorJobAggregator implements AggregatorInterface "{$p}_history", Join::WITH, $qb->expr()->andX( - $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->eq("{$p}_history.user", 'acpw.createdBy'), $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->lte("{$p}_history.startDate", 'acpw.createdAt'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + $qb->expr()->gt("{$p}_history.endDate", 'acpw.createdAt') ) ) ) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php index fdbbf56a4..c57607693 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregator.php @@ -44,12 +44,12 @@ class CreatorScopeAggregator implements AggregatorInterface "{$p}_history", Join::WITH, $qb->expr()->andX( - $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->eq("{$p}_history.user", 'acpw.createdBy'), $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->lte("{$p}_history.startDate", 'acpw.createdAt'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + $qb->expr()->gt("{$p}_history.endDate", 'acpw.createdAt') ) ) ) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php index 47b5f4c9c..2b7a6ef07 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorJobFilter.php @@ -46,12 +46,12 @@ class CreatorJobFilter implements FilterInterface "{$p}_history", Join::WITH, $qb->expr()->andX( - $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->eq("{$p}_history.user", 'acpw.createdBy'), $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->lte("{$p}_history.startDate", 'acpw.createdAt'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + $qb->expr()->gt("{$p}_history.endDate", 'acpw.createdAt') ) ) ) diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php index 996aa5272..16ed52755 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/SocialWorkFilters/CreatorScopeFilter.php @@ -46,12 +46,12 @@ class CreatorScopeFilter implements FilterInterface "{$p}_history", Join::WITH, $qb->expr()->andX( - $qb->expr()->eq("{$p}_history.user", "acpw.createdBy"), + $qb->expr()->eq("{$p}_history.user", 'acpw.createdBy'), $qb->expr()->andX( - $qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"), + $qb->expr()->lte("{$p}_history.startDate", 'acpw.createdAt'), $qb->expr()->orX( $qb->expr()->isNull("{$p}_history.endDate"), - $qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt") + $qb->expr()->gt("{$p}_history.endDate", 'acpw.createdAt') ) ) ) diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 41e0140c8..046d553e9 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -100,7 +100,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [ From 200ab836c72134e92673b87ecc8c9705aa021c09 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 14:50:21 +0100 Subject: [PATCH 07/12] test cs-fixer --- .../ChillActivityBundle/Controller/ActivityController.php | 4 ++-- src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php | 2 +- tests/Kernel.php | 2 +- tests/app/config/bundles.php | 3 +-- tests/symfony-container.php | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 43c0b13bb..06489010c 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -673,8 +673,8 @@ final class ActivityController extends AbstractController throw $this->createNotFoundException('Accompanying Period not found'); } - // TODO Add permission - // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); + // TODO Add permission + // $this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person); } else { throw $this->createNotFoundException('Person or Accompanying Period not found'); } diff --git a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php index 046d553e9..41e0140c8 100644 --- a/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php +++ b/src/Bundle/ChillThirdPartyBundle/Form/ThirdPartyType.php @@ -100,7 +100,7 @@ class ThirdPartyType extends AbstractType 'label' => 'thirdparty.Contact data are confidential', ]); - // Institutional ThirdParty (parent) + // Institutional ThirdParty (parent) } else { $builder ->add('nameCompany', TextType::class, [ diff --git a/tests/Kernel.php b/tests/Kernel.php index a0ede51ac..1b3d0de82 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -26,7 +26,7 @@ class Kernel extends BaseKernel public function registerBundles(): iterable { - $contents = require __DIR__ . '/app/config/bundles.php'; + $contents = require __DIR__.'/app/config/bundles.php'; foreach ($contents as $class => $envs) { if ($envs[$this->environment] ?? $envs['all'] ?? false) { diff --git a/tests/app/config/bundles.php b/tests/app/config/bundles.php index 36e3bcf03..e728a729f 100644 --- a/tests/app/config/bundles.php +++ b/tests/app/config/bundles.php @@ -34,7 +34,7 @@ return [ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - //Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + // Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], @@ -44,5 +44,4 @@ return [ ChampsLibres\WopiBundle\WopiBundle::class => ['all' => true], Chill\WopiBundle\ChillWopiBundle::class => ['all' => true], \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], - ]; diff --git a/tests/symfony-container.php b/tests/symfony-container.php index fd093e94d..f4f494948 100644 --- a/tests/symfony-container.php +++ b/tests/symfony-container.php @@ -11,7 +11,7 @@ declare(strict_types=1); use App\Kernel; -require __DIR__ . '/bootstrap.php'; +require __DIR__.'/bootstrap.php'; $appKernel = new Kernel('test', false); $appKernel->boot(); From 3cdad6caff72e1e5b4d31d08fccf233a8dca1ef6 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 14:58:31 +0100 Subject: [PATCH 08/12] Revert "test cs-fixer" This reverts commit 9aa1d22d69e0f67333a8c39574fa2efed71c2bc8. --- tests/Kernel.php | 2 +- tests/app/config/bundles.php | 3 ++- tests/symfony-container.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Kernel.php b/tests/Kernel.php index 1b3d0de82..a0ede51ac 100644 --- a/tests/Kernel.php +++ b/tests/Kernel.php @@ -26,7 +26,7 @@ class Kernel extends BaseKernel public function registerBundles(): iterable { - $contents = require __DIR__.'/app/config/bundles.php'; + $contents = require __DIR__ . '/app/config/bundles.php'; foreach ($contents as $class => $envs) { if ($envs[$this->environment] ?? $envs['all'] ?? false) { diff --git a/tests/app/config/bundles.php b/tests/app/config/bundles.php index e728a729f..36e3bcf03 100644 --- a/tests/app/config/bundles.php +++ b/tests/app/config/bundles.php @@ -34,7 +34,7 @@ return [ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], - // Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], + //Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], Knp\Bundle\MenuBundle\KnpMenuBundle::class => ['all' => true], Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true], @@ -44,4 +44,5 @@ return [ ChampsLibres\WopiBundle\WopiBundle::class => ['all' => true], Chill\WopiBundle\ChillWopiBundle::class => ['all' => true], \Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true], + ]; diff --git a/tests/symfony-container.php b/tests/symfony-container.php index f4f494948..fd093e94d 100644 --- a/tests/symfony-container.php +++ b/tests/symfony-container.php @@ -11,7 +11,7 @@ declare(strict_types=1); use App\Kernel; -require __DIR__.'/bootstrap.php'; +require __DIR__ . '/bootstrap.php'; $appKernel = new Kernel('test', false); $appKernel->boot(); From 7f18a2fb7da07715d0b77094f457abe9f3584fe9 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 14 Nov 2023 15:39:29 +0100 Subject: [PATCH 09/12] [export] better translation since filters are sorted --- src/Bundle/ChillPersonBundle/translations/messages.fr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 12705cb29..459a75286 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -576,7 +576,7 @@ Group by number of actions: Grouper les parcours par nombre d’actions Filter by creator: Filtrer les parcours par créateur 'Filtered by creator: only %creators%': 'Filtré par créateur: uniquement %creators%' -Filter actions without end date: Filtre les actions sans date de fin (ouvertes) +Filter actions without end date: Filtrer les actions sans date de fin (ouvertes) Filtered actions without end date: 'Filtré: uniquement les actions sans date de fin (ouvertes)' Filter by start date evaluations: Filtrer les évaluations par date de début Filter by end date evaluations: Filtrer les évaluations par date de fin @@ -1192,14 +1192,14 @@ export: work: start_between_dates: - title: Filtre les actions d'accompagnement dont la date d'ouverture est entre deux dates + title: Filtrer les actions dont la date d'ouverture est entre deux dates start_date: Date de début end_date: Date de fin keep_null: Conserver les actions dont la date de début n'est pas indiquée keep_null_help: Si coché, les actions dont la date de début est vide seront prises en compte. Si non coché, elles ne seront pas comptabilisée. Only where start date is between %startDate% and %endDate%: Seulement les actions dont la date de début est entre le %startDate% et le %endDate% end_between_dates: - title: Filtre les actions d'accompagnement dont la date de clotûre est entre deux dates (ou l'action est toujours ouverte) + title: Filtrer les actions dont la date de clotûre est entre deux dates (ou l'action est toujours ouverte) start_date: Date de début end_date: Date de fin keep_null: Conserver les actions dont la date de fin n'est pas indiquée (actions en cours) From f9763b866d9744c93b95bfbaf9ef0cd30841158d Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 15 Nov 2023 11:59:55 +0100 Subject: [PATCH 10/12] add 6 new tests for filters/aggrs --- .../CreatorAggregatorTest.php | 60 ++++++++++++++++ .../CreatorJobAggregatorTest.php | 60 ++++++++++++++++ .../CreatorScopeAggregatorTest.php | 60 ++++++++++++++++ .../SocialWorkFilters/CreatorFilterTest.php | 70 +++++++++++++++++++ .../CreatorJobFilterTest.php | 70 +++++++++++++++++++ .../CreatorScopeFilterTest.php | 69 ++++++++++++++++++ .../translations/messages.fr.yml | 4 +- 7 files changed, 391 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregatorTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorJobFilterTest.php create mode 100644 src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorScopeFilterTest.php diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorAggregatorTest.php new file mode 100644 index 000000000..18921db7b --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorAggregatorTest.php @@ -0,0 +1,60 @@ +aggregator = self::$container->get(CreatorAggregator::class); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData() + { + return [ + [], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregatorTest.php new file mode 100644 index 000000000..98699db0e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorJobAggregatorTest.php @@ -0,0 +1,60 @@ +aggregator = self::$container->get(CreatorJobAggregator::class); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData() + { + return [ + [], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregatorTest.php new file mode 100644 index 000000000..df424792c --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/SocialWorkAggregators/CreatorScopeAggregatorTest.php @@ -0,0 +1,60 @@ +aggregator = self::$container->get(CreatorScopeAggregator::class); + } + + public function getAggregator() + { + return $this->aggregator; + } + + public function getFormData() + { + return [ + [], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('count(acp.id)') + ->from(AccompanyingPeriod::class, 'acp') + ->join('acp.works', 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorFilterTest.php new file mode 100644 index 000000000..a8ba33350 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorFilterTest.php @@ -0,0 +1,70 @@ +filter = self::$container->get(CreatorFilter::class); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + $creators = $em->createQuery('SELECT u FROM '.User::class.' u') + ->setMaxResults(1) + ->getResult(); + + return [ + [ + 'creators' => $creators, + ], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('acpw.id') + ->from(AccompanyingPeriodWork::class, 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorJobFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorJobFilterTest.php new file mode 100644 index 000000000..51a4a288e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorJobFilterTest.php @@ -0,0 +1,70 @@ +filter = self::$container->get(CreatorJobFilter::class); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $jobs = $em->createQuery('SELECT j FROM '.UserJob::class.' j') + ->setMaxResults(1) + ->getResult(); + + return [ + [ + 'jobs' => new ArrayCollection($jobs), + ], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('acpw.id') + ->from(AccompanyingPeriodWork::class, 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorScopeFilterTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorScopeFilterTest.php new file mode 100644 index 000000000..cac5856bd --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Filter/SocialWorkFilters/CreatorScopeFilterTest.php @@ -0,0 +1,69 @@ +filter = self::$container->get(CreatorScopeFilter::class); + } + + public function getFilter() + { + return $this->filter; + } + + public function getFormData() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $scopes = $em->createQuery('SELECT s FROM '.Scope::class.' s') + ->setMaxResults(1) + ->getResult(); + + return [ + [ + 'scopes' => $scopes, + ], + ]; + } + + public function getQueryBuilders() + { + self::bootKernel(); + + $em = self::$container->get(EntityManagerInterface::class); + + return [ + $em->createQueryBuilder() + ->select('acpw.id') + ->from(AccompanyingPeriodWork::class, 'acpw'), + ]; + } +} diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 459a75286..4768b8355 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -1229,10 +1229,10 @@ export: "Filtered by creator: only %creators%": "Filtré par créateur de l'action: uniquement %creators%" by_creator_job: title: Filtrer les actions par métier du créateur - "Filtered by creator job: only %jobs%'": "Filtré par métier du créateur: uniquement %jobs%" + "Filtered by creator job: only %jobs%": "Filtré par métier du créateur: uniquement %jobs%" by_creator_scope: title: Filtrer les actions par service du créateur - "Filtered by creator scope: only %scopes%'": "Filtré par service du créateur: uniquement %scopes%" + "Filtered by creator scope: only %scopes%": "Filtré par service du créateur: uniquement %scopes%" list: person_with_acp: From f5f4d8fcdd85f3738b12b44533e6a7554ee9da87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 15 Nov 2023 13:30:48 +0100 Subject: [PATCH 11/12] remove blank line in changie --- .changes/unreleased/Feature-20231114-143558.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.changes/unreleased/Feature-20231114-143558.yaml b/.changes/unreleased/Feature-20231114-143558.yaml index edc72c027..d95691b73 100644 --- a/.changes/unreleased/Feature-20231114-143558.yaml +++ b/.changes/unreleased/Feature-20231114-143558.yaml @@ -1,7 +1,6 @@ kind: Feature body: |+ Add 3 new filters and 3 new aggregators for work action creator (with jobs and scopes) - time: 2023-11-14T14:35:58.099418749+01:00 custom: Issue: "204" From e6cab938c8be55f66ce34f53f789e4a248ece239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 15 Nov 2023 13:41:35 +0100 Subject: [PATCH 12/12] DX: increase max connection in postgres service --- .gitlab-ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 32b7e5221..dc3e39778 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,6 +11,10 @@ cache: services: - name: postgis/postgis:14-3.3-alpine alias: db + command: + - postgres + - "-c" + - max_connections=1000 - name: redis alias: redis