From bb1602934c5705561290bc012f2ca4d3d001091a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 7 Nov 2023 16:07:24 +0100 Subject: [PATCH] Fix "group activity by creator job" aggregator --- .changes/unreleased/Fixed-20231107-160702.yaml | 5 +++++ ...copeAggregator.php => CreatorJobAggregator.php} | 14 ++++++-------- ...egatorTest.php => CreatorJobAggregatorTest.php} | 8 ++++---- .../config/services/export.yaml | 2 +- .../translations/messages.fr.yml | 4 ++-- 5 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 .changes/unreleased/Fixed-20231107-160702.yaml rename src/Bundle/ChillActivityBundle/Export/Aggregator/{JobScopeAggregator.php => CreatorJobAggregator.php} (87%) rename src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/{JobScopeAggregatorTest.php => CreatorJobAggregatorTest.php} (81%) diff --git a/.changes/unreleased/Fixed-20231107-160702.yaml b/.changes/unreleased/Fixed-20231107-160702.yaml new file mode 100644 index 000000000..46ac4810d --- /dev/null +++ b/.changes/unreleased/Fixed-20231107-160702.yaml @@ -0,0 +1,5 @@ +kind: Fixed +body: Fix "group activity by creator job" aggregator +time: 2023-11-07T16:07:02.576354444+01:00 +custom: + Issue: "" diff --git a/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorJobAggregator.php similarity index 87% rename from src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php rename to src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorJobAggregator.php index e43f430d5..d57670e7f 100644 --- a/src/Bundle/ChillActivityBundle/Export/Aggregator/JobScopeAggregator.php +++ b/src/Bundle/ChillActivityBundle/Export/Aggregator/CreatorJobAggregator.php @@ -14,18 +14,18 @@ namespace Chill\ActivityBundle\Export\Aggregator; use Chill\ActivityBundle\Export\Declarations; use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Export\AggregatorInterface; -use Chill\MainBundle\Repository\ScopeRepository; +use Chill\MainBundle\Repository\UserJobRepositoryInterface; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; -class JobScopeAggregator implements AggregatorInterface +class CreatorJobAggregator implements AggregatorInterface { private const PREFIX = 'acp_agg_creator_job'; public function __construct( - private readonly ScopeRepository $scopeRepository, + private readonly UserJobRepositoryInterface $userJobRepository, private readonly TranslatableStringHelper $translatableStringHelper ) {} @@ -76,17 +76,15 @@ class JobScopeAggregator implements AggregatorInterface { return function ($value): string { if ('_header' === $value) { - return 'Scope'; + return 'Job'; } - if (null === $value || '' === $value) { + if (null === $value || '' === $value || null === $s = $this->userJobRepository->find($value)) { return ''; } - $s = $this->scopeRepository->find($value); - return $this->translatableStringHelper->localize( - $s->getName() + $s->getLabel() ); }; } diff --git a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorJobAggregatorTest.php similarity index 81% rename from src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php rename to src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorJobAggregatorTest.php index 69d511ace..9a821de75 100644 --- a/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/JobScopeAggregatorTest.php +++ b/src/Bundle/ChillActivityBundle/Tests/Export/Aggregator/CreatorJobAggregatorTest.php @@ -12,7 +12,7 @@ declare(strict_types=1); namespace Chill\ActivityBundle\Tests\Export\Aggregator; use Chill\ActivityBundle\Entity\Activity; -use Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator; +use Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator; use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Doctrine\ORM\EntityManagerInterface; @@ -21,15 +21,15 @@ use Doctrine\ORM\EntityManagerInterface; * * @coversNothing */ -final class JobScopeAggregatorTest extends AbstractAggregatorTest +final class CreatorJobAggregatorTest extends AbstractAggregatorTest { - private JobScopeAggregator $aggregator; + private CreatorJobAggregator $aggregator; protected function setUp(): void { self::bootKernel(); - $this->aggregator = self::$container->get(JobScopeAggregator::class); + $this->aggregator = self::$container->get(CreatorJobAggregator::class); } public function getAggregator() diff --git a/src/Bundle/ChillActivityBundle/config/services/export.yaml b/src/Bundle/ChillActivityBundle/config/services/export.yaml index cb269b0f4..29f7c2625 100644 --- a/src/Bundle/ChillActivityBundle/config/services/export.yaml +++ b/src/Bundle/ChillActivityBundle/config/services/export.yaml @@ -183,7 +183,7 @@ services: tags: - { name: chill.export_aggregator, alias: activity_creator_scope_aggregator } - Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator: + Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator: tags: - { name: chill.export_aggregator, alias: activity_creator_job_aggregator } diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 56b69fe6c..759d222c1 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -416,8 +416,8 @@ export: Group activity by creator scope: Grouper les échanges par service du créateur de l'échange Calc date: Date de calcul du service du créateur de l'échange by_creator_job: - Group activity by creator job: Grouper les échanges par service du créateur de l'échange - Calc date: Date de calcul du service du créateur de l'échange + Group activity by creator job: Grouper les échanges par métier du créateur de l'échange + Calc date: Date de calcul du métier du créateur de l'échange by_persons: Group activity by persons: Grouper les échanges par usager participant Persons: Usagers participants