Fixed: [export][activity] use createdBy property instead of user for

grouping or filtering by creator
This commit is contained in:
2022-10-14 21:43:30 +02:00
parent cd3fc99b9a
commit c07cd2b715
9 changed files with 41 additions and 60 deletions

View File

@@ -13,20 +13,19 @@ namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators;
use Chill\ActivityBundle\Export\Declarations;
use Chill\MainBundle\Export\AggregatorInterface;
use Chill\MainBundle\Repository\UserRepository;
use Chill\MainBundle\Repository\UserRepositoryInterface;
use Chill\MainBundle\Templating\Entity\UserRender;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class ByUserAggregator implements AggregatorInterface
class ByCreatorAggregator implements AggregatorInterface
{
private UserRender $userRender;
private UserRepository $userRepository;
private UserRepositoryInterface $userRepository;
public function __construct(
UserRepository $userRepository,
UserRepositoryInterface $userRepository,
UserRender $userRender
) {
$this->userRepository = $userRepository;
@@ -40,12 +39,8 @@ class ByUserAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('actusers', $qb->getAllAliases(), true)) {
$qb->leftJoin('activity.users', 'actusers');
}
$qb->addSelect('actusers.id AS users_aggregator');
$qb->addGroupBy('users_aggregator');
$qb->addSelect('IDENTITY(activity.createdBy) AS creator_aggregator');
$qb->addGroupBy('creator_aggregator');
}
public function applyOn(): string
@@ -62,7 +57,7 @@ class ByUserAggregator implements AggregatorInterface
{
return function ($value): string {
if ('_header' === $value) {
return 'Accepted users';
return 'Created by';
}
if (null === $value) {
@@ -77,11 +72,11 @@ class ByUserAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['users_aggregator'];
return ['creator_aggregator'];
}
public function getTitle(): string
{
return 'Group activity by linked users';
return 'Group activity by creator';
}
}

View File

@@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\FormBuilderInterface;
use function in_array;
class UserScopeAggregator implements AggregatorInterface
class CreatorScopeAggregator implements AggregatorInterface
{
private ScopeRepository $scopeRepository;
@@ -40,12 +40,12 @@ class UserScopeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
if (!in_array('actuser', $qb->getAllAliases(), true)) {
$qb->leftJoin('activity.user', 'actuser');
if (!in_array('actcreator', $qb->getAllAliases(), true)) {
$qb->leftJoin('activity.createdBy', 'actcreator');
}
$qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator');
$qb->addGroupBy('userscope_aggregator');
$qb->addSelect('IDENTITY(actcreator.mainScope) AS creatorscope_aggregator');
$qb->addGroupBy('creatorscope_aggregator');
}
public function applyOn(): string
@@ -79,11 +79,11 @@ class UserScopeAggregator implements AggregatorInterface
public function getQueryKeys($data): array
{
return ['userscope_aggregator'];
return ['creatorscope_aggregator'];
}
public function getTitle(): string
{
return 'Group activity by userscope';
return 'Group activity by creator scope';
}
}