mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
[export] fix aside activity filters/aggregators: 'at' based on aside date
This commit is contained in:
parent
31fc7fffe9
commit
6e48d036d7
@ -14,23 +14,17 @@ namespace Chill\AsideActivityBundle\Export\Aggregator;
|
|||||||
use Chill\AsideActivityBundle\Export\Declarations;
|
use Chill\AsideActivityBundle\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\Form\Type\PickRollingDateType;
|
|
||||||
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
use Chill\MainBundle\Repository\UserJobRepositoryInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
use function in_array;
|
|
||||||
|
|
||||||
class ByUserJobAggregator implements AggregatorInterface
|
class ByUserJobAggregator implements AggregatorInterface
|
||||||
{
|
{
|
||||||
private const PREFIX = 'aside_act_agg_user_job';
|
private const PREFIX = 'aside_act_agg_user_job';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly RollingDateConverter $rollingDateConverter,
|
|
||||||
private readonly UserJobRepositoryInterface $userJobRepository,
|
private readonly UserJobRepositoryInterface $userJobRepository,
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
||||||
) {}
|
) {}
|
||||||
@ -49,23 +43,20 @@ class ByUserJobAggregator implements AggregatorInterface
|
|||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserJobHistory::class,
|
UserJobHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
Expr\Join::WITH,
|
Join::WITH,
|
||||||
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
||||||
)
|
)
|
||||||
|
// job_at based on aside.date
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"),
|
$qb->expr()->lte("{$p}_history.startDate", "aside.date"),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", ":{$p}_at")
|
$qb->expr()->gt("{$p}_history.endDate", "aside.date")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->addSelect("IDENTITY({$p}_history.job) AS {$p}_select")
|
->addSelect("IDENTITY({$p}_history.job) AS {$p}_select")
|
||||||
->setParameter(
|
|
||||||
"{$p}_at",
|
|
||||||
$this->rollingDateConverter->convert($data['job_at'])
|
|
||||||
)
|
|
||||||
->addGroupBy("{$p}_select");
|
->addGroupBy("{$p}_select");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,15 +67,11 @@ class ByUserJobAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('job_at', PickRollingDateType::class, [
|
|
||||||
'label' => 'export.aggregator.by_user_job.Calc date',
|
|
||||||
'required' => true
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['job_at' => new RollingDate(RollingDate::T_TODAY)];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
|
@ -14,12 +14,9 @@ namespace Chill\AsideActivityBundle\Export\Aggregator;
|
|||||||
use Chill\AsideActivityBundle\Export\Declarations;
|
use Chill\AsideActivityBundle\Export\Declarations;
|
||||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||||
use Chill\MainBundle\Export\AggregatorInterface;
|
use Chill\MainBundle\Export\AggregatorInterface;
|
||||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
|
||||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\ORM\Query\Expr;
|
use Doctrine\ORM\Query\Expr\Join;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
||||||
@ -28,7 +25,6 @@ class ByUserScopeAggregator implements AggregatorInterface
|
|||||||
private const PREFIX = 'aside_act_agg_user_scope';
|
private const PREFIX = 'aside_act_agg_user_scope';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly RollingDateConverter $rollingDateConverter,
|
|
||||||
private readonly ScopeRepositoryInterface $scopeRepository,
|
private readonly ScopeRepositoryInterface $scopeRepository,
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
||||||
) {}
|
) {}
|
||||||
@ -47,23 +43,19 @@ class ByUserScopeAggregator implements AggregatorInterface
|
|||||||
->leftJoin(
|
->leftJoin(
|
||||||
UserScopeHistory::class,
|
UserScopeHistory::class,
|
||||||
"{$p}_history",
|
"{$p}_history",
|
||||||
Expr\Join::WITH,
|
Join::WITH,
|
||||||
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
$qb->expr()->eq("{$p}_history.user", "{$p}_user")
|
||||||
)
|
)
|
||||||
->andWhere(
|
->andWhere(
|
||||||
$qb->expr()->andX(
|
$qb->expr()->andX(
|
||||||
$qb->expr()->lte("{$p}_history.startDate", ":{$p}_at"),
|
$qb->expr()->lte("{$p}_history.startDate", "aside.date"),
|
||||||
$qb->expr()->orX(
|
$qb->expr()->orX(
|
||||||
$qb->expr()->isNull("{$p}_history.endDate"),
|
$qb->expr()->isNull("{$p}_history.endDate"),
|
||||||
$qb->expr()->gt("{$p}_history.endDate", ":{$p}_at")
|
$qb->expr()->gt("{$p}_history.endDate", "aside.date")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select")
|
->addSelect("IDENTITY({$p}_history.scope) AS {$p}_select")
|
||||||
->setParameter(
|
|
||||||
"{$p}_at",
|
|
||||||
$this->rollingDateConverter->convert($data['scope_at'])
|
|
||||||
)
|
|
||||||
->addGroupBy("{$p}_select");
|
->addGroupBy("{$p}_select");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,15 +66,11 @@ class ByUserScopeAggregator implements AggregatorInterface
|
|||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder)
|
public function buildForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add('scope_at', PickRollingDateType::class, [
|
|
||||||
'label' => 'export.aggregator.by_user_scope.Calc date',
|
|
||||||
'required' => true,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormDefaultData(): array
|
public function getFormDefaultData(): array
|
||||||
{
|
{
|
||||||
return ['scope_at' => new RollingDate(RollingDate::T_TODAY)];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLabels($key, array $values, $data)
|
public function getLabels($key, array $values, $data)
|
||||||
|
@ -16,9 +16,6 @@ use Chill\AsideActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\User\UserJobHistory;
|
use Chill\MainBundle\Entity\User\UserJobHistory;
|
||||||
use Chill\MainBundle\Entity\UserJob;
|
use Chill\MainBundle\Entity\UserJob;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
@ -29,7 +26,6 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
private const PREFIX = 'aside_act_filter_user_job';
|
private const PREFIX = 'aside_act_filter_user_job';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly RollingDateConverter $rollingDateConverter,
|
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@ -49,14 +45,14 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
. "JOIN {$p}_act.agent {$p}_user "
|
. "JOIN {$p}_act.agent {$p}_user "
|
||||||
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
. "JOIN " . UserJobHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||||
. "WHERE {$p}_act = aside "
|
. "WHERE {$p}_act = aside "
|
||||||
. "AND {$p}_history.startDate <= :{$p}_at "
|
// job_at based on aside.date
|
||||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > :{$p}_at) "
|
. "AND {$p}_history.startDate <= aside.date "
|
||||||
|
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||||
. "AND {$p}_history.job IN ( :{$p}_jobs )"
|
. "AND {$p}_history.job IN ( :{$p}_jobs )"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters([
|
||||||
"{$p}_jobs" => $data["jobs"],
|
"{$p}_jobs" => $data["jobs"],
|
||||||
"{$p}_at" => $this->rollingDateConverter->convert($data["job_at"])
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,10 +69,6 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
'choice_label' => fn (UserJob $j) => $this->translatableStringHelper->localize($j->getLabel()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
])
|
|
||||||
->add('job_at', PickRollingDateType::class, [
|
|
||||||
'label' => 'export.filter.by_user_job.Calc date',
|
|
||||||
'required' => true
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +89,6 @@ class ByUserJobFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'jobs' => [],
|
'jobs' => [],
|
||||||
'job_at' => new RollingDate(RollingDate::T_TODAY)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,10 +16,7 @@ use Chill\AsideActivityBundle\Export\Declarations;
|
|||||||
use Chill\MainBundle\Entity\Scope;
|
use Chill\MainBundle\Entity\Scope;
|
||||||
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
use Chill\MainBundle\Entity\User\UserScopeHistory;
|
||||||
use Chill\MainBundle\Export\FilterInterface;
|
use Chill\MainBundle\Export\FilterInterface;
|
||||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
|
||||||
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
use Chill\MainBundle\Repository\ScopeRepositoryInterface;
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDate;
|
|
||||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverter;
|
|
||||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
@ -30,7 +27,6 @@ class ByUserScopeFilter implements FilterInterface
|
|||||||
private const PREFIX = 'aside_act_filter_user_scope';
|
private const PREFIX = 'aside_act_filter_user_scope';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly RollingDateConverter $rollingDateConverter,
|
|
||||||
private readonly ScopeRepositoryInterface $scopeRepository,
|
private readonly ScopeRepositoryInterface $scopeRepository,
|
||||||
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
private readonly TranslatableStringHelperInterface $translatableStringHelper
|
||||||
) {}
|
) {}
|
||||||
@ -51,14 +47,14 @@ class ByUserScopeFilter implements FilterInterface
|
|||||||
. "JOIN {$p}_act.agent {$p}_user "
|
. "JOIN {$p}_act.agent {$p}_user "
|
||||||
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
. "JOIN " . UserScopeHistory::class . " {$p}_history WITH {$p}_history.user = {$p}_user "
|
||||||
. "WHERE {$p}_act = aside "
|
. "WHERE {$p}_act = aside "
|
||||||
. "AND {$p}_history.startDate <= :{$p}_at "
|
// scope_at based on aside.date
|
||||||
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > :{$p}_at) "
|
. "AND {$p}_history.startDate <= aside.date "
|
||||||
|
. "AND ({$p}_history.endDate IS NULL OR {$p}_history.endDate > aside.date) "
|
||||||
. "AND {$p}_history.scope IN ( :{$p}_scopes )"
|
. "AND {$p}_history.scope IN ( :{$p}_scopes )"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
->setParameters([
|
->setParameters([
|
||||||
"{$p}_scopes" => $data["scopes"],
|
"{$p}_scopes" => $data["scopes"],
|
||||||
"{$p}_at" => $this->rollingDateConverter->convert($data["scope_at"])
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +72,6 @@ class ByUserScopeFilter implements FilterInterface
|
|||||||
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
'choice_label' => fn (Scope $s) => $this->translatableStringHelper->localize($s->getName()),
|
||||||
'multiple' => true,
|
'multiple' => true,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
])
|
|
||||||
->add('scope_at', PickRollingDateType::class, [
|
|
||||||
'label' => 'export.filter.by_user_scope.Calc date',
|
|
||||||
'required' => true,
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +92,6 @@ class ByUserScopeFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'scopes' => [],
|
'scopes' => [],
|
||||||
'scope_at' => new RollingDate(RollingDate::T_TODAY)
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,11 +203,9 @@ export:
|
|||||||
by_user_job:
|
by_user_job:
|
||||||
'Filtered aside activities by user jobs: only %jobs%': "Filtré par métier des utilisateurs: uniquement %jobs%"
|
'Filtered aside activities by user jobs: only %jobs%': "Filtré par métier des utilisateurs: uniquement %jobs%"
|
||||||
Filter by user jobs: Filtrer les activités annexes par métier des utilisateurs
|
Filter by user jobs: Filtrer les activités annexes par métier des utilisateurs
|
||||||
Calc date: Date de calcul du métier des utilisateurs
|
|
||||||
by_user_scope:
|
by_user_scope:
|
||||||
'Filtered aside activities by user scope: only %scopes%': "Filtré par service des utilisateurs: uniquement %scopes%"
|
'Filtered aside activities by user scope: only %scopes%': "Filtré par service des utilisateurs: uniquement %scopes%"
|
||||||
Filter by user scope: Filtrer les activités annexes par service d'utilisateur
|
Filter by user scope: Filtrer les activités annexes par service d'utilisateur
|
||||||
Calc date: Date de calcul du service des utilisateurs
|
|
||||||
Filter by aside activity location: Filtrer les activités annexes par localisation
|
Filter by aside activity location: Filtrer les activités annexes par localisation
|
||||||
'Filtered by aside activity location: only %location%': "Filtré par localisation: uniquement %location%"
|
'Filtered by aside activity location: only %location%': "Filtré par localisation: uniquement %location%"
|
||||||
aggregator:
|
aggregator:
|
||||||
@ -215,10 +213,8 @@ export:
|
|||||||
Aside activity type: Type d'activité annexe
|
Aside activity type: Type d'activité annexe
|
||||||
by_user_job:
|
by_user_job:
|
||||||
Aggregate by user job: Grouper les activités annexes par métier des utilisateurs
|
Aggregate by user job: Grouper les activités annexes par métier des utilisateurs
|
||||||
Calc date: Date de calcul du métier des utilisateurs
|
|
||||||
by_user_scope:
|
by_user_scope:
|
||||||
Aggregate by user scope: Grouper les activités annexes par service des utilisateurs
|
Aggregate by user scope: Grouper les activités annexes par service des utilisateurs
|
||||||
Calc date: Date de calcul du service des utilisateurs
|
|
||||||
Aside activity location: Localisation des activités annexe
|
Aside activity location: Localisation des activités annexe
|
||||||
Group by aside activity location: Grouper les activités annexes par localisation
|
Group by aside activity location: Grouper les activités annexes par localisation
|
||||||
Aside activity localisation: Localisation
|
Aside activity localisation: Localisation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user