exports: add condition with distinct alias on join clauses

This commit is contained in:
2022-09-07 19:58:38 +02:00
parent 81359877c4
commit 1dcff2f23c
49 changed files with 343 additions and 220 deletions

View File

@@ -40,9 +40,11 @@ final class AgentAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.user', 'u');
if (!in_array('caluser', $qb->getAllAliases(), true)) {
$qb->join('cal.user', 'caluser');
}
$qb->addSelect('u.id AS agent_aggregator');
$qb->addSelect('caluser.id AS agent_aggregator');
$groupBy = $qb->getDQLPart('groupBy');

View File

@@ -41,7 +41,9 @@ class CancelReasonAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
// TODO: still needs to take into account appointments without a cancel reason somehow
$qb->join('cal.cancelReason', 'cr');
if (!in_array('calcancel', $qb->getAllAliases(), true)) {
$qb->join('cal.cancelReason', 'calcancel');
}
$qb->addSelect('IDENTITY(cal.cancelReason) as cancel_reason_aggregator');

View File

@@ -40,9 +40,11 @@ final class JobAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.user', 'u');
if (!in_array('caluser', $qb->getAllAliases(), true)) {
$qb->join('cal.user', 'caluser');
}
$qb->addSelect('IDENTITY(u.userJob) as job_aggregator');
$qb->addSelect('IDENTITY(caluser.userJob) as job_aggregator');
$groupBy = $qb->getDQLPart('groupBy');

View File

@@ -36,7 +36,9 @@ final class LocationAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.location', 'l');
if (!in_array('calloc', $qb->getAllAliases(), true)) {
$qb->join('cal.location', 'calloc');
}
$qb->addSelect('IDENTITY(cal.location) as location_aggregator');
$groupBy = $qb->getDQLPart('groupBy');

View File

@@ -40,9 +40,11 @@ final class LocationTypeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.location', 'l');
if (!in_array('calloc', $qb->getAllAliases(), true)) {
$qb->join('cal.location', 'calloc');
}
$qb->addSelect('IDENTITY(l.locationType) as location_type_aggregator');
$qb->addSelect('IDENTITY(calloc.locationType) as location_type_aggregator');
$groupBy = $qb->getDQLPart('groupBy');

View File

@@ -40,9 +40,11 @@ final class ScopeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.user', 'u');
if (!in_array('caluser', $qb->getAllAliases(), true)) {
$qb->join('cal.user', 'caluser');
}
$qb->addSelect('IDENTITY(u.mainScope) as scope_aggregator');
$qb->addSelect('IDENTITY(caluser.mainScope) as scope_aggregator');
$groupBy = $qb->getDQLPart('groupBy');

View File

@@ -42,10 +42,12 @@ class JobFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.user', 'u');
if (!in_array('caluser', $qb->getAllAliases(), true)) {
$qb->join('cal.user', 'caluser');
}
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('u.userJob', ':job');
$clause = $qb->expr()->in('caluser.userJob', ':job');
if ($where instanceof Andx) {
$where->add($clause);

View File

@@ -42,10 +42,12 @@ class ScopeFilter implements FilterInterface
public function alterQuery(QueryBuilder $qb, $data)
{
$qb->join('cal.user', 'u');
if (!in_array('caluser', $qb->getAllAliases(), true)) {
$qb->join('cal.user', 'caluser');
}
$where = $qb->getDQLPart('where');
$clause = $qb->expr()->in('u.mainScope', ':scope');
$clause = $qb->expr()->in('caluser.mainScope', ':scope');
if ($where instanceof Andx) {
$where->add($clause);