Fix filtres and scopes to take into account job and scope when the refferrer is add to the accompanying period work

This commit is contained in:
2023-10-16 10:58:41 +02:00
parent 63e9d1a96f
commit 68d28f3e28
24 changed files with 352 additions and 173 deletions

View File

@@ -182,7 +182,10 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn
{
$qb = $this->em->createQueryBuilder()
->from(AsideActivity::class, 'aside')
->leftJoin('aside.agent', 'agent');
->leftJoin('aside.agent', 'agent')
->leftJoin('agent.scopeHistories', 'scopeHistories')
->andWhere('scopeHistories.startDate <= aside.date AND (scopeHistories.endDate IS NULL or scopeHistories.endDate > aside.date)')
;
$qb
->addSelect('aside.id AS id')
@@ -190,7 +193,7 @@ final readonly class ListAsideActivity implements ListInterface, GroupedExportIn
->addSelect('aside.updatedAt AS updatedAt')
->addSelect('IDENTITY(aside.agent) AS agent_id')
->addSelect('IDENTITY(aside.createdBy) AS creator_id')
->addSelect('IDENTITY(agent.mainScope) AS main_scope') ///
->addSelect('IDENTITY(scopeHistories.scope) AS main_scope')
->addSelect('IDENTITY(agent.mainCenter) AS main_center')
->addSelect('IDENTITY(aside.type) AS aside_activity_type')
->addSelect('aside.date')

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\AsideActivityBundle\Tests\Export\Export;
use Chill\AsideActivityBundle\Export\Export\ListAsideActivity;
use Chill\MainBundle\Test\Export\AbstractExportTest;
use Doctrine\ORM\AbstractQuery;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class ListAsideActivityTest extends KernelTestCase
{
private ListAsideActivity $listAsideActivity;
protected function setUp(): void
{
parent::setUp();
self::bootKernel();
$this->listAsideActivity = self::$container->get(ListAsideActivity::class);
}
public function testExecuteQuery(): void
{
$qb = $this->listAsideActivity->initiateQuery([], [], [])
->setMaxResults(1);
$results = $qb->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
self::assertIsArray($results, "smoke test: test that the result is an array");
}
}