add condition on join clause to improve combined Filters/Aggregators

This commit is contained in:
Mathieu Jaumotte 2022-08-11 18:09:25 +02:00
parent 619ae4e458
commit 4e12684f98
5 changed files with 15 additions and 12 deletions

View File

@ -78,10 +78,10 @@ final class EvaluationAggregator implements AggregatorInterface
*/
public function alterQuery(QueryBuilder $qb, $data)
{
$qb
->join('acp.works', 'acpw')
->join('acpw.accompanyingPeriodWorkEvaluations', 'we')
;
if (!in_array('acpw', $qb->getAllAliases())) {
$qb->join('acp.works', 'acpw');
}
$qb->join('acpw.accompanyingPeriodWorkEvaluations', 'we');
$qb->addSelect('IDENTITY(we.evaluation) AS evaluation_aggregator');

View File

@ -76,7 +76,9 @@ final class SocialActionAggregator implements AggregatorInterface
*/
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('acp.works', 'acpw');
if (!in_array('acpw', $qb->getAllAliases())) {
$qb->join('acp.works', 'acpw');
}
$qb->addSelect('IDENTITY(acpw.socialAction) AS socialaction_aggregator'); // DISTINCT ??

View File

@ -69,9 +69,10 @@ class SocialActionFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('acp.works', 'acpw')
->join('acpw.socialAction', 'sa')
;
if (!in_array('acpw', $qb->getAllAliases())) {
$qb->join('acp.works', 'acpw');
}
$qb->join('acpw.socialAction', 'sa');
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('sa.id', ':socialactions');

View File

@ -72,10 +72,10 @@ class JobFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('acpw.referrers', 'r');
$qb->join('acpw.referrers', 'u');
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('r.userJob', ':job');
$clause = $qb->expr()->in('u.userJob', ':job');
if ($where instanceof Andx) {
$where->add($clause);

View File

@ -71,10 +71,10 @@ class ScopeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('acpw.referrers', 'r');
$qb->join('acpw.referrers', 'u');
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('r.mainScope', ':scope');
$clause = $qb->expr()->in('u.mainScope', ':scope');
if ($where instanceof Andx) {
$where->add($clause);