mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fixed: [export][activity] use createdBy property instead of user for
grouping or filtering by creator
This commit is contained in:
parent
cd3fc99b9a
commit
c07cd2b715
@ -60,6 +60,7 @@ These are alias conventions :
|
|||||||
| | User::class | activity.users | actusers |
|
| | User::class | activity.users | actusers |
|
||||||
| | ActivityReason::class | activity.reasons | actreasons |
|
| | ActivityReason::class | activity.reasons | actreasons |
|
||||||
| | Center::class | actperson.center | actcenter |
|
| | Center::class | actperson.center | actcenter |
|
||||||
|
| | Person::class | activity.createdBy | actcreator |
|
||||||
| ActivityReason::class | | | actreasons |
|
| ActivityReason::class | | | actreasons |
|
||||||
| | ActivityReasonCategory::class | actreason.category | actreasoncat |
|
| | ActivityReasonCategory::class | actreason.category | actreasoncat |
|
||||||
| Calendar::class | | | cal |
|
| Calendar::class | | | cal |
|
||||||
|
@ -13,20 +13,19 @@ namespace Chill\ActivityBundle\Export\Aggregator\ACPAggregators;
|
|||||||
|
|
||||||
use Chill\ActivityBundle\Export\Declarations;
|
use Chill\ActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Repository\UserRepository;
|
use Chill\MainBundle\Repository\UserRepositoryInterface;
|
||||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ByUserAggregator implements AggregatorInterface
|
class ByCreatorAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
private UserRender $userRender;
|
private UserRender $userRender;
|
||||||
|
|
||||||
private UserRepository $userRepository;
|
private UserRepositoryInterface $userRepository;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
UserRepository $userRepository,
|
UserRepositoryInterface $userRepository,
|
||||||
UserRender $userRender
|
UserRender $userRender
|
||||||
) {
|
) {
|
||||||
$this->userRepository = $userRepository;
|
$this->userRepository = $userRepository;
|
||||||
@ -40,12 +39,8 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
$qb->addSelect('IDENTITY(activity.createdBy) AS creator_aggregator');
|
||||||
$qb->leftJoin('activity.users', 'actusers');
|
$qb->addGroupBy('creator_aggregator');
|
||||||
}
|
|
||||||
|
|
||||||
$qb->addSelect('actusers.id AS users_aggregator');
|
|
||||||
$qb->addGroupBy('users_aggregator');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -62,7 +57,7 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
{
|
{
|
||||||
return function ($value): string {
|
return function ($value): string {
|
||||||
if ('_header' === $value) {
|
if ('_header' === $value) {
|
||||||
return 'Accepted users';
|
return 'Created by';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $value) {
|
if (null === $value) {
|
||||||
@ -77,11 +72,11 @@ class ByUserAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return ['users_aggregator'];
|
return ['creator_aggregator'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Group activity by linked users';
|
return 'Group activity by creator';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder;
|
|||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
use function in_array;
|
||||||
|
|
||||||
class UserScopeAggregator implements AggregatorInterface
|
class CreatorScopeAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
private ScopeRepository $scopeRepository;
|
private ScopeRepository $scopeRepository;
|
||||||
|
|
||||||
@ -40,12 +40,12 @@ class UserScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
if (!in_array('actuser', $qb->getAllAliases(), true)) {
|
if (!in_array('actcreator', $qb->getAllAliases(), true)) {
|
||||||
$qb->leftJoin('activity.user', 'actuser');
|
$qb->leftJoin('activity.createdBy', 'actcreator');
|
||||||
}
|
}
|
||||||
|
|
||||||
$qb->addSelect('IDENTITY(actuser.mainScope) AS userscope_aggregator');
|
$qb->addSelect('IDENTITY(actcreator.mainScope) AS creatorscope_aggregator');
|
||||||
$qb->addGroupBy('userscope_aggregator');
|
$qb->addGroupBy('creatorscope_aggregator');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -79,11 +79,11 @@ class UserScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function getQueryKeys($data): array
|
public function getQueryKeys($data): array
|
||||||
{
|
{
|
||||||
return ['userscope_aggregator'];
|
return ['creatorscope_aggregator'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Group activity by userscope';
|
return 'Group activity by creator scope';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,12 +15,10 @@ use Chill\ActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
use Chill\MainBundle\Form\Type\PickUserDynamicType;
|
||||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||||
use Doctrine\ORM\Query\Expr\Andx;
|
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ByUserFilter implements FilterInterface
|
class ByCreatorFilter implements FilterInterface
|
||||||
{
|
{
|
||||||
private UserRender $userRender;
|
private UserRender $userRender;
|
||||||
|
|
||||||
@ -36,22 +34,11 @@ class ByUserFilter implements FilterInterface
|
|||||||
|
|
||||||
public function alterQuery(QueryBuilder $qb, $data)
|
public function alterQuery(QueryBuilder $qb, $data)
|
||||||
{
|
{
|
||||||
$where = $qb->getDQLPart('where');
|
$qb
|
||||||
|
->andWhere(
|
||||||
if (!in_array('actusers', $qb->getAllAliases(), true)) {
|
$qb->expr()->in('activity.createdBy', ':users')
|
||||||
$qb->join('activity.users', 'actusers');
|
)
|
||||||
}
|
->setParameter('users', $data['accepted_users']);
|
||||||
|
|
||||||
$clause = $qb->expr()->in('actusers.id', ':users');
|
|
||||||
|
|
||||||
if ($where instanceof Andx) {
|
|
||||||
$where->add($clause);
|
|
||||||
} else {
|
|
||||||
$where = $qb->expr()->andX($clause);
|
|
||||||
}
|
|
||||||
|
|
||||||
$qb->add('where', $where);
|
|
||||||
$qb->setParameter('users', $data['accepted_users']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applyOn(): string
|
public function applyOn(): string
|
||||||
@ -74,13 +61,13 @@ class ByUserFilter implements FilterInterface
|
|||||||
$users[] = $this->userRender->renderString($u, []);
|
$users[] = $this->userRender->renderString($u, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['Filtered activity by linked users: only %users%', [
|
return ['Filtered activity by creator: only %users%', [
|
||||||
'%users%' => implode(', ou ', $users),
|
'%users%' => implode(', ou ', $users),
|
||||||
]];
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Filter activity by linked users';
|
return 'Filter activity by creator';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
|
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByUserAggregator;
|
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByCreatorAggregator;
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
final class ByUserAggregatorTest extends AbstractAggregatorTest
|
final class ByUserAggregatorTest extends AbstractAggregatorTest
|
||||||
{
|
{
|
||||||
private ByUserAggregator $aggregator;
|
private ByCreatorAggregator $aggregator;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
|
namespace Chill\ActivityBundle\Tests\Export\Aggregator\ACPAggregators;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\UserScopeAggregator;
|
use Chill\ActivityBundle\Export\Aggregator\ACPAggregators\CreatorScopeAggregator;
|
||||||
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
use Chill\MainBundle\Test\Export\AbstractAggregatorTest;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
final class UserScopeAggregatorTest extends AbstractAggregatorTest
|
final class UserScopeAggregatorTest extends AbstractAggregatorTest
|
||||||
{
|
{
|
||||||
private UserScopeAggregator $aggregator;
|
private CreatorScopeAggregator $aggregator;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ declare(strict_types=1);
|
|||||||
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
namespace Chill\ActivityBundle\Tests\Export\Filter\ACPFilters;
|
||||||
|
|
||||||
use Chill\ActivityBundle\Entity\Activity;
|
use Chill\ActivityBundle\Entity\Activity;
|
||||||
use Chill\ActivityBundle\Export\Filter\ACPFilters\ByUserFilter;
|
use Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter;
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
use Chill\MainBundle\Test\Export\AbstractFilterTest;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
@ -23,7 +23,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
*/
|
*/
|
||||||
final class ByUserFilterTest extends AbstractFilterTest
|
final class ByUserFilterTest extends AbstractFilterTest
|
||||||
{
|
{
|
||||||
private ByUserFilter $filter;
|
private ByCreatorFilter $filter;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
|
@ -77,10 +77,9 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: 'activity_locationtype_filter' }
|
- { name: chill.export_filter, alias: 'activity_locationtype_filter' }
|
||||||
|
|
||||||
chill.activity.export.byuser_filter: # TMS (M2M)
|
Chill\ActivityBundle\Export\Filter\ACPFilters\ByCreatorFilter:
|
||||||
class: Chill\ActivityBundle\Export\Filter\ACPFilters\ByUserFilter
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: 'activity_byuser_filter' }
|
- { name: chill.export_filter, alias: 'activity_bycreator_filter' }
|
||||||
|
|
||||||
chill.activity.export.emergency_filter:
|
chill.activity.export.emergency_filter:
|
||||||
class: Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter
|
class: Chill\ActivityBundle\Export\Filter\ACPFilters\EmergencyFilter
|
||||||
@ -138,10 +137,9 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_date_aggregator }
|
- { name: chill.export_aggregator, alias: activity_date_aggregator }
|
||||||
|
|
||||||
chill.activity.export.byuser_aggregator:
|
Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByCreatorAggregator:
|
||||||
class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByUserAggregator
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_byuser_aggregator }
|
- { name: chill.export_aggregator, alias: activity_by_creator_aggregator }
|
||||||
|
|
||||||
chill.activity.export.bythirdparty_aggregator:
|
chill.activity.export.bythirdparty_aggregator:
|
||||||
class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator
|
class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\ByThirdpartyAggregator
|
||||||
@ -158,7 +156,6 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_bysocialissue_aggregator }
|
- { name: chill.export_aggregator, alias: activity_bysocialissue_aggregator }
|
||||||
|
|
||||||
chill.activity.export.userscope_aggregator:
|
Chill\ActivityBundle\Export\Aggregator\ACPAggregators\CreatorScopeAggregator:
|
||||||
class: Chill\ActivityBundle\Export\Aggregator\ACPAggregators\UserScopeAggregator
|
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_aggregator, alias: activity_userscope_aggregator }
|
- { name: chill.export_aggregator, alias: activity_creator_scope_aggregator }
|
||||||
|
@ -252,8 +252,8 @@ Filter by activity type: Filtrer les activités par type
|
|||||||
Filter activity by locationtype: Filtrer les activités par type de localisation
|
Filter activity by locationtype: Filtrer les activités par type de localisation
|
||||||
'Filtered activity by locationtype: only %types%': "Filtré par type de localisation: uniquement %types%"
|
'Filtered activity by locationtype: only %types%': "Filtré par type de localisation: uniquement %types%"
|
||||||
Accepted locationtype: Types de localisation
|
Accepted locationtype: Types de localisation
|
||||||
Filter activity by linked users: Filtrer les activités par TMS
|
Filter activity by creator: Filtrer les activités par créateur de l'échange
|
||||||
'Filtered activity by linked users: only %users%': "Filtré par TMS: uniquement %users%"
|
'Filtered activity by creator: only %users%': "Filtré par créateur de l'échange: uniquement %users%"
|
||||||
Accepted users: TMS(s)
|
Accepted users: TMS(s)
|
||||||
Filter activity by emergency: Filtrer les activités par urgence
|
Filter activity by emergency: Filtrer les activités par urgence
|
||||||
'Filtered activity by emergency: only %emergency%': "Filtré par urgence: uniquement si %emergency%"
|
'Filtered activity by emergency: only %emergency%': "Filtré par urgence: uniquement si %emergency%"
|
||||||
@ -294,7 +294,8 @@ by week: Par semaine
|
|||||||
for week: Semaine
|
for week: Semaine
|
||||||
by year: Par année
|
by year: Par année
|
||||||
in year: En
|
in year: En
|
||||||
Group activity by linked users: Grouper les activités par TMS impliqué
|
Group activity by creator: Grouper les activités par créateur de l'échange
|
||||||
|
Group activity by creator scope: Grouper les activités par service du créateur de l'échange
|
||||||
Group activity by linked thirdparties: Grouper les activités par tiers impliqué
|
Group activity by linked thirdparties: Grouper les activités par tiers impliqué
|
||||||
Accepted thirdparty: Tiers impliqué
|
Accepted thirdparty: Tiers impliqué
|
||||||
Group activity by linked socialaction: Grouper les activités par action liée
|
Group activity by linked socialaction: Grouper les activités par action liée
|
||||||
|
Loading…
x
Reference in New Issue
Block a user