[export][person] Fixed: use left join on association between works and

goal/results
This commit is contained in:
Julien Fastré 2022-09-26 17:02:28 +02:00
parent 95f7622923
commit e3764f6f91
3 changed files with 10 additions and 15 deletions

View File

@ -40,7 +40,7 @@ final class ActionTypeAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) { if (!in_array('acpwsocialaction', $qb->getAllAliases(), true)) {
$qb->join('acpw.socialAction', 'acpwsocialaction'); $qb->leftJoin('acpw.socialAction', 'acpwsocialaction');
} }
$qb->addSelect('acpwsocialaction.id as action_type_aggregator'); $qb->addSelect('acpwsocialaction.id as action_type_aggregator');

View File

@ -35,6 +35,10 @@ class GoalResultAggregator implements AggregatorInterface
public function getLabels($key, array $values, $data) public function getLabels($key, array $values, $data)
{ {
return function ($value) use ($key): string { return function ($value) use ($key): string {
if (null === $value) {
return '';
}
switch ($key) { switch ($key) {
case 'goal_aggregator': case 'goal_aggregator':
@ -107,25 +111,16 @@ class GoalResultAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
if (!in_array('goal', $qb->getAllAliases(), true)) { if (!in_array('goal', $qb->getAllAliases(), true)) {
$qb->join('acpw.goals', 'goal'); $qb->leftJoin('acpw.goals', 'goal');
} }
if (!in_array('goalresult', $qb->getAllAliases(), true)) { if (!in_array('goalresult', $qb->getAllAliases(), true)) {
$qb->join('goal.results', 'goalresult'); $qb->leftJoin('goal.results', 'goalresult');
} }
$qb->addSelect('IDENTITY(goal.goal) as goal_aggregator'); $qb->addSelect('IDENTITY(goal.goal) as goal_aggregator');
$qb->addSelect('goalresult.id as result_aggregator'); $qb->addSelect('goalresult.id as result_aggregator');
$qb->addGroupBy('goal_aggregator')->addGroupBy('result_aggregator');
$groupBy = $qb->getDQLPart('groupBy');
if (!empty($groupBy)) {
$qb->addGroupBy('goal_aggregator');
} else {
$qb->groupBy('goal_aggregator');
}
$qb->addGroupBy('result_aggregator');
} }
/** /**
@ -135,4 +130,4 @@ class GoalResultAggregator implements AggregatorInterface
{ {
return Declarations::SOCIAL_WORK_ACTION_TYPE; return Declarations::SOCIAL_WORK_ACTION_TYPE;
} }
} }

View File

@ -38,7 +38,7 @@ final class ResultAggregator implements AggregatorInterface
public function alterQuery(QueryBuilder $qb, $data) public function alterQuery(QueryBuilder $qb, $data)
{ {
if (!in_array('result', $qb->getAllAliases(), true)) { if (!in_array('result', $qb->getAllAliases(), true)) {
$qb->join('acpw.results', 'result'); $qb->leftJoin('acpw.results', 'result');
} }
$qb->addSelect('result.id AS acpw_result_aggregator'); $qb->addSelect('result.id AS acpw_result_aggregator');