filters alterQuery

This commit is contained in:
Mathieu Jaumotte 2023-11-14 13:43:28 +01:00
parent 3892d1e877
commit fde6000d0b
3 changed files with 39 additions and 9 deletions

View File

@ -22,8 +22,6 @@ class CreatorFilter implements FilterInterface
{
private const PREFIX = 'acpw_filter_creator';
public function __construct() {}
public function addRole(): ?string
{
return null;
@ -34,7 +32,7 @@ class CreatorFilter implements FilterInterface
$p = self::PREFIX;
$qb
->join('acpw.createdBy', "{$p}_creator")
->leftJoin('acpw.createdBy', "{$p}_creator")
->andWhere($qb->expr()->in("{$p}_creator", ":{$p}_creators"))
->setParameter("{$p}_creators", $data['creators']);
}

View File

@ -11,11 +11,13 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\User\UserJobHistory;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
@ -39,9 +41,23 @@ class CreatorJobFilter implements FilterInterface
$p = self::PREFIX;
$qb
->setParameter("{$p}_jobs", $data['jobs'])
;
->leftJoin(
UserJobHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_history.user", "acpw.createdBy"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt")
)
)
)
)
->andWhere($qb->expr()->in("{$p}_history.job", ":{$p}_jobs"))
->setParameter("{$p}_jobs", $data['jobs']);
}
public function applyOn(): string

View File

@ -12,10 +12,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Export\Filter\SocialWorkFilters;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User\UserScopeHistory;
use Chill\MainBundle\Export\FilterInterface;
use Chill\MainBundle\Repository\ScopeRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\PersonBundle\Export\Declarations;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\FormBuilderInterface;
@ -39,9 +41,23 @@ class CreatorScopeFilter implements FilterInterface
$p = self::PREFIX;
$qb
->setParameter("{$p}_scopes", $data['scopes'])
;
->leftJoin(
UserScopeHistory::class,
"{$p}_history",
Join::WITH,
$qb->expr()->andX(
$qb->expr()->eq("{$p}_history.user", "acpw.createdBy"),
$qb->expr()->andX(
$qb->expr()->lte("{$p}_history.startDate", "acpw.createdAt"),
$qb->expr()->orX(
$qb->expr()->isNull("{$p}_history.endDate"),
$qb->expr()->gt("{$p}_history.endDate", "acpw.createdAt")
)
)
)
)
->andWhere($qb->expr()->in("{$p}_history.scope", ":{$p}_scopes"))
->setParameter("{$p}_scopes", $data['scopes']);
}
public function applyOn(): string