Fix "group activity by creator job" aggregator

This commit is contained in:
2023-11-07 16:07:24 +01:00
parent 83fe3ec3fc
commit bb1602934c
5 changed files with 18 additions and 15 deletions

View File

@@ -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()
);
};
}