Fix "group activity by creator job" aggregator

This commit is contained in:
Julien Fastré 2023-11-07 16:07:24 +01:00
parent 83fe3ec3fc
commit bb1602934c
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
5 changed files with 18 additions and 15 deletions

View File

@ -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: ""

View File

@ -14,18 +14,18 @@ namespace Chill\ActivityBundle\Export\Aggregator;
use Chill\ActivityBundle\Export\Declarations; use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Entity\User\UserJobHistory; use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Export\AggregatorInterface; use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\ScopeRepository; use Chill\MainBundle\Repository\UserJobRepositoryInterface;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
class JobScopeAggregator implements AggregatorInterface class CreatorJobAggregator implements AggregatorInterface
{ {
private const PREFIX = 'acp_agg_creator_job'; private const PREFIX = 'acp_agg_creator_job';
public function __construct( public function __construct(
private readonly ScopeRepository $scopeRepository, private readonly UserJobRepositoryInterface $userJobRepository,
private readonly TranslatableStringHelper $translatableStringHelper private readonly TranslatableStringHelper $translatableStringHelper
) {} ) {}
@ -76,17 +76,15 @@ class JobScopeAggregator implements AggregatorInterface
{ {
return function ($value): string { return function ($value): string {
if ('_header' === $value) { if ('_header' === $value) {
return 'Scope'; return 'Job';
} }
if (null === $value || '' === $value) { if (null === $value || '' === $value || null === $s = $this->userJobRepository->find($value)) {
return ''; return '';
} }
$s = $this->scopeRepository->find($value);
return $this->translatableStringHelper->localize( return $this->translatableStringHelper->localize(
$s->getName() $s->getLabel()
); );
}; };
} }

View File

@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\Tests\Export\Aggregator; namespace Chill\ActivityBundle\Tests\Export\Aggregator;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator; use Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator;
use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
@ -21,15 +21,15 @@ use Doctrine\ORM\EntityManagerInterface;
* *
* @coversNothing * @coversNothing
*/ */
final class JobScopeAggregatorTest extends AbstractAggregatorTest final class CreatorJobAggregatorTest extends AbstractAggregatorTest
{ {
private JobScopeAggregator $aggregator; private CreatorJobAggregator $aggregator;
protected function setUp(): void protected function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->aggregator = self::$container->get(JobScopeAggregator::class); $this->aggregator = self::$container->get(CreatorJobAggregator::class);
} }
public function getAggregator() public function getAggregator()

View File

@ -183,7 +183,7 @@ services:
tags: tags:
- { name: chill.export_aggregator, alias: activity_creator_scope_aggregator } - { name: chill.export_aggregator, alias: activity_creator_scope_aggregator }
Chill\ActivityBundle\Export\Aggregator\JobScopeAggregator: Chill\ActivityBundle\Export\Aggregator\CreatorJobAggregator:
tags: tags:
- { name: chill.export_aggregator, alias: activity_creator_job_aggregator } - { name: chill.export_aggregator, alias: activity_creator_job_aggregator }

View File

@ -416,8 +416,8 @@ export:
Group activity by creator scope: Grouper les échanges par service du créateur de l'échange 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 Calc date: Date de calcul du service du créateur de l'échange
by_creator_job: by_creator_job:
Group activity by creator job: Grouper les échanges par 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 service du créateur de l'échange Calc date: Date de calcul du métier du créateur de l'échange
by_persons: by_persons:
Group activity by persons: Grouper les échanges par usager participant Group activity by persons: Grouper les échanges par usager participant
Persons: Usagers participants Persons: Usagers participants