Fixed: [export] improve memory footprint for filter by Geographical Unit

This commit is contained in:
2022-11-03 13:59:16 +01:00
parent 82d9ab8ca6
commit df4f5e7cf8
5 changed files with 84 additions and 19 deletions

View File

@@ -0,0 +1,52 @@
<?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\MainBundle\Entity\GeographicalUnit;
/**
* Simple GeographialUnit Data Transfer Object.
*
* This allow to get access to id, unitName, unitRefId, and layer's id
*/
class SimpleGeographicalUnitDTO
{
/**
* @readonly
* @psalm-readonly
*/
public int $id;
/**
* @readonly
* @psalm-readonly
*/
public int $layerId;
/**
* @readonly
* @psalm-readonly
*/
public string $unitName;
/**
* @readonly
* @psalm-readonly
*/
public string $unitRefId;
public function __construct(int $id, string $unitName, string $unitRefId, int $layerId)
{
$this->id = $id;
$this->unitName = $unitName;
$this->unitRefId = $unitRefId;
$this->layerId = $layerId;
}
}

View File

@@ -205,6 +205,7 @@ class ExportAddressHelper
case 'floor':
case '_lat':
case '_lon':
case 'steps':
case 'postcode_code':
case 'postcode_name':
return static function ($value) use ($sanitizedKey, $translationPrefix) {

View File

@@ -41,7 +41,7 @@ class GeographicalUnitRepository implements GeographicalUnitRepositoryInterface
{
return $this->repository
->createQueryBuilder('gu')
->select('PARTIAL gu.{id,unitName,unitRefId,layer}')
->select(sprintf('NEW %s(gu.id, gu.unitName, gu.unitRefId, IDENTITY(gu.layer))', GeographicalUnit\SimpleGeographicalUnitDTO::class))
->addOrderBy('IDENTITY(gu.layer)')
->addOrderBy(('gu.unitName'))
->getQuery()