From 80835dd7c3feecd0d775a7c75cadb4258b8676e1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 8 Feb 2023 15:59:42 +0000 Subject: [PATCH] Fixed: [export][filter by user's job] take into account the job associated to the user instead of the one associated to the course --- .../{JobAggregator.php => UserJobAggregator.php} | 8 ++++---- .../Filter/AccompanyingCourseFilters/UserJobFilter.php | 8 -------- .../{JobAggregatorTest.php => UserJobAggregatorTest.php} | 6 +++--- .../config/services/exports_accompanying_course.yaml | 2 +- 4 files changed, 8 insertions(+), 16 deletions(-) rename src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/{JobAggregator.php => UserJobAggregator.php} (89%) rename src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/{JobAggregatorTest.php => UserJobAggregatorTest.php} (90%) diff --git a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php similarity index 89% rename from src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php rename to src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php index 5019d3a8b..a8acdcf12 100644 --- a/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/JobAggregator.php +++ b/src/Bundle/ChillPersonBundle/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregator.php @@ -19,7 +19,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; use function in_array; -final class JobAggregator implements AggregatorInterface +final class UserJobAggregator implements AggregatorInterface { private UserJobRepository $jobRepository; @@ -40,11 +40,11 @@ final class JobAggregator implements AggregatorInterface public function alterQuery(QueryBuilder $qb, $data) { - if (!in_array('acpjob', $qb->getAllAliases(), true)) { - $qb->leftJoin('acp.job', 'acpjob'); + if (!in_array('acpuser', $qb->getAllAliases(), true)) { + $qb->leftJoin('acp.user', 'acpuser'); } - $qb->addSelect('IDENTITY(acp.job) AS job_aggregator'); + $qb->addSelect('IDENTITY(acpuser.userJob) AS job_aggregator'); $qb->addGroupBy('job_aggregator'); } diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php index b97f97dda..2b69c528b 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/AccompanyingCourseFilters/UserJobFilter.php @@ -126,12 +126,4 @@ class UserJobFilter implements FilterInterface { return 'Filter by user job'; } - - private function getUserJob(): UserJob - { - /** @var User $user */ - $user = $this->security->getUser(); - - return $user->getUserJob(); - } } diff --git a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php similarity index 90% rename from src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php rename to src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php index 18ef84c15..1ed748e32 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/JobAggregatorTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Export/Aggregator/AccompanyingCourseAggregators/UserJobAggregatorTest.php @@ -13,16 +13,16 @@ namespace Chill\PersonBundle\Tests\Export\Aggregator\AccompanyingCourseAggregato use Chill\MainBundle\Test\Export\AbstractAggregatorTest; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator; +use Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserJobAggregator; use Doctrine\ORM\EntityManagerInterface; /** * @internal * @coversNothing */ -final class JobAggregatorTest extends AbstractAggregatorTest +final class UserJobAggregatorTest extends AbstractAggregatorTest { - private JobAggregator $aggregator; + private UserJobAggregator $aggregator; protected function setUp(): void { diff --git a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml index 6d0e160fd..bb2cfa556 100644 --- a/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/exports_accompanying_course.yaml @@ -136,7 +136,7 @@ services: - { name: chill.export_aggregator, alias: accompanyingcourse_scope_aggregator } chill.person.export.aggregator_referrer_job: - class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\JobAggregator + class: Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators\UserJobAggregator tags: - { name: chill.export_aggregator, alias: accompanyingcourse_referrer_job_aggregator }