mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
exports: test all activity filters/aggregators and fix errors
This commit is contained in:
@@ -61,7 +61,11 @@ class BySocialActionAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('IDENTITY(activity.socialActions) AS socialaction_aggregator');
|
||||
if(!in_array('socialaction', $qb->getAllAliases())) {
|
||||
$qb->join('activity.socialActions', 'socialaction');
|
||||
}
|
||||
|
||||
$qb->addSelect('socialaction.id AS socialaction_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -62,7 +62,11 @@ class BySocialIssueAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('IDENTITY(activity.socialIssues) AS socialissue_aggregator');
|
||||
if (!in_array('socialissue', $qb->getAllAliases())) {
|
||||
$qb->join('activity.socialIssues', 'socialissue');
|
||||
}
|
||||
|
||||
$qb->addSelect('socialissue.id AS socialissue_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -30,7 +30,7 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
||||
{
|
||||
return function ($value): string {
|
||||
if ($value === '_header') {
|
||||
return 'Thirdparty';
|
||||
return 'Accepted thirdparty';
|
||||
}
|
||||
|
||||
$tp = $this->thirdPartyRepository->find($value);
|
||||
@@ -61,7 +61,11 @@ class ByThirdpartyAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('IDENTITY(activity.thirdParties) AS thirdparty_aggregator');
|
||||
if (!in_array('thirdparty', $qb->getAllAliases())) {
|
||||
$qb->join('activity.thirdParties', 'thirdparty');
|
||||
}
|
||||
|
||||
$qb->addSelect('thirdparty.id AS thirdparty_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -61,7 +61,11 @@ class ByUserAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('IDENTITY(activity.users) AS users_aggregator');
|
||||
if (!in_array('user', $qb->getAllAliases())) {
|
||||
$qb->join('activity.users', 'user');
|
||||
}
|
||||
|
||||
$qb->addSelect('user.id AS users_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -16,7 +16,7 @@ class DateAggregator implements AggregatorInterface
|
||||
{
|
||||
private const CHOICES = [
|
||||
'by month' => 'month',
|
||||
'by week' => 'week', // sur base du numéro de la semaine
|
||||
'by week' => 'week', // numéro de la semaine
|
||||
'by year' => 'year',
|
||||
];
|
||||
|
||||
@@ -60,6 +60,7 @@ class DateAggregator implements AggregatorInterface
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('by_date', ChoiceType::class, [
|
||||
'label' => 'Frequency',
|
||||
'choices' => self::CHOICES,
|
||||
'multiple' => false,
|
||||
'expanded' => true,
|
||||
|
@@ -63,7 +63,11 @@ class LocationTypeAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
$qb->addSelect('IDENTITY(activity.location) AS locationtype_aggregator');
|
||||
if (!in_array('location', $qb->getAllAliases())) {
|
||||
$qb->join('activity.location', 'location');
|
||||
}
|
||||
|
||||
$qb->addSelect('IDENTITY(location.locationType) AS locationtype_aggregator');
|
||||
|
||||
$groupBy = $qb->getDQLPart('groupBy');
|
||||
|
||||
|
@@ -15,6 +15,7 @@ use Chill\ActivityBundle\Export\Declarations;
|
||||
use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Chill\MainBundle\Templating\Entity\UserRender;
|
||||
use Closure;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
@@ -26,10 +27,14 @@ class ActivityUserAggregator implements AggregatorInterface
|
||||
|
||||
private UserRepository $userRepository;
|
||||
|
||||
private UserRender $userRender;
|
||||
|
||||
public function __construct(
|
||||
UserRepository $userRepository
|
||||
UserRepository $userRepository,
|
||||
UserRender $userRender
|
||||
) {
|
||||
$this->userRepository = $userRepository;
|
||||
$this->userRender = $userRender;
|
||||
}
|
||||
|
||||
public function addRole()
|
||||
@@ -63,10 +68,12 @@ class ActivityUserAggregator implements AggregatorInterface
|
||||
|
||||
return function ($value) {
|
||||
if ('_header' === $value) {
|
||||
return 'activity user';
|
||||
return 'Activity user';
|
||||
}
|
||||
|
||||
return $this->userRepository->find($value)->getUsername();
|
||||
$u = $this->userRepository->find($value);
|
||||
|
||||
return $this->userRender->renderString($u, []);
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ class BySocialActionFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by linked socialaction: only %actions%', [
|
||||
'%actions%' => implode(", ou", $actions)
|
||||
'%actions%' => implode(", ou ", $actions)
|
||||
]];
|
||||
}
|
||||
|
||||
@@ -61,7 +61,11 @@ class BySocialActionFilter implements FilterInterface
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
$clause = $qb->expr()->in('activity.socialActions', ':socialactions');
|
||||
if (!in_array('socialaction', $qb->getAllAliases())) {
|
||||
$qb->join('activity.socialActions', 'socialaction');
|
||||
}
|
||||
|
||||
$clause = $qb->expr()->in('socialaction.id', ':socialactions');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
|
@@ -48,7 +48,7 @@ class BySocialIssueFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by linked socialissue: only %issues%', [
|
||||
'%issues%' => implode(", ou", $issues)
|
||||
'%issues%' => implode(", ou ", $issues)
|
||||
]];
|
||||
}
|
||||
|
||||
@@ -61,7 +61,11 @@ class BySocialIssueFilter implements FilterInterface
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
$clause = $qb->expr()->in('activity.socialIssues', ':socialissues');
|
||||
if (!in_array('socialissue', $qb->getAllAliases())) {
|
||||
$qb->join('activity.socialIssues', 'socialissue');
|
||||
}
|
||||
|
||||
$clause = $qb->expr()->in('socialissue.id', ':socialissues');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
|
@@ -48,7 +48,7 @@ class ByUserFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by linked users: only %users%', [
|
||||
'%users%' => implode(", ou", $users)
|
||||
'%users%' => implode(", ou ", $users)
|
||||
]];
|
||||
}
|
||||
|
||||
@@ -61,7 +61,11 @@ class ByUserFilter implements FilterInterface
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
|
||||
$clause = $qb->expr()->in('activity.users', ':users');
|
||||
if (!in_array('user', $qb->getAllAliases())) {
|
||||
$qb->join('activity.users', 'user');
|
||||
}
|
||||
|
||||
$clause = $qb->expr()->in('user.id', ':users');
|
||||
|
||||
if ($where instanceof Andx) {
|
||||
$where->add($clause);
|
||||
|
@@ -50,7 +50,7 @@ class LocationTypeFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by locationtype: only %types%', [
|
||||
'%types%' => implode(", ou", $types)
|
||||
'%types%' => implode(", ou ", $types)
|
||||
]];
|
||||
}
|
||||
|
||||
|
@@ -49,7 +49,7 @@ class UserFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by user: only %users%', [
|
||||
'%users%' => implode(", ou", $users)
|
||||
'%users%' => implode(", ou ", $users)
|
||||
]];
|
||||
}
|
||||
|
||||
|
@@ -52,7 +52,7 @@ class UserScopeFilter implements FilterInterface
|
||||
}
|
||||
|
||||
return ['Filtered activity by userscope: only %scopes%', [
|
||||
'%scopes%' => implode(", ou", $scopes)
|
||||
'%scopes%' => implode(", ou ", $scopes)
|
||||
]];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user