mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 22:35:01 +00:00
Merge branch '111_exports_suite' of gitlab.com:Chill-Projet/chill-bundles into 111_exports_suite
This commit is contained in:
@@ -12,7 +12,6 @@ declare(strict_types=1);
|
||||
namespace Chill\PersonBundle\Export\Aggregator\AccompanyingCourseAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Entity\GeographicalUnit;
|
||||
use Chill\MainBundle\Entity\GeographicalUnitLayer;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
@@ -27,7 +26,6 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use UnexpectedValueException;
|
||||
use function in_array;
|
||||
|
||||
final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
{
|
||||
@@ -54,63 +52,50 @@ final class GeographicalUnitStatAggregator implements AggregatorInterface
|
||||
|
||||
public function alterQuery(QueryBuilder $qb, $data)
|
||||
{
|
||||
if (!in_array('acp_geog_agg_location_history', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin('acp.locationHistories', 'acp_geog_agg_location_history');
|
||||
$qb->leftJoin('acp.locationHistories', 'acp_geog_agg_location_history');
|
||||
|
||||
$qb->andWhere(
|
||||
$qb->expr()->andX(
|
||||
'acp_geog_agg_location_history.startDate <= :acp_geog_aggregator_date',
|
||||
$qb->expr()->orX(
|
||||
$qb->andWhere(
|
||||
$qb->expr()->andX(
|
||||
'acp_geog_agg_location_history.startDate <= :acp_geog_aggregator_date',
|
||||
$qb->expr()->orX(
|
||||
'acp_geog_agg_location_history.endDate IS NULL',
|
||||
'acp_geog_agg_location_history.endDate > :acp_geog_aggregator_date'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$qb->setParameter(
|
||||
'acp_geog_aggregator_date',
|
||||
$this->rollingDateConverter->convert($data['date_calc'])
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// link between location history and person
|
||||
if (!in_array('acp_geog_agg_address_person_location', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
PersonHouseholdAddress::class,
|
||||
'acp_geog_agg_address_person_location',
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
'IDENTITY(acp_geog_agg_address_person_location.person) = IDENTITY(acp_geog_agg_location_history.personLocation)',
|
||||
'acp_geog_agg_address_person_location.validFrom < :acp_geog_aggregator_date',
|
||||
$qb->expr()->orX(
|
||||
$qb->leftJoin(
|
||||
PersonHouseholdAddress::class,
|
||||
'acp_geog_agg_address_person_location',
|
||||
Join::WITH,
|
||||
$qb->expr()->andX(
|
||||
'IDENTITY(acp_geog_agg_address_person_location.person) = IDENTITY(acp_geog_agg_location_history.personLocation)',
|
||||
'acp_geog_agg_address_person_location.validFrom < :acp_geog_aggregator_date',
|
||||
$qb->expr()->orX(
|
||||
'acp_geog_agg_address_person_location.validTo > :acp_geog_aggregator_date',
|
||||
$qb->expr()->isNull('acp_geog_agg_address_person_location.validTo')
|
||||
)
|
||||
)
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
$qb->setParameter(
|
||||
'acp_geog_aggregator_date',
|
||||
$this->rollingDateConverter->convert($data['date_calc'])
|
||||
);
|
||||
}
|
||||
$qb->setParameter(
|
||||
'acp_geog_aggregator_date',
|
||||
$this->rollingDateConverter->convert($data['date_calc'])
|
||||
);
|
||||
|
||||
// we finally find an address
|
||||
if (!in_array('acp_geog_agg_address', $qb->getAllAliases(), true)) {
|
||||
$qb->leftJoin(
|
||||
Address::class,
|
||||
'acp_geog_agg_address',
|
||||
Join::WITH,
|
||||
'COALESCE(IDENTITY(acp_geog_agg_address_person_location.address), IDENTITY(acp_geog_agg_location_history.addressLocation)) = acp_geog_agg_address.id'
|
||||
);
|
||||
}
|
||||
$qb->leftJoin(
|
||||
Address::class,
|
||||
'acp_geog_agg_address',
|
||||
Join::WITH,
|
||||
'COALESCE(IDENTITY(acp_geog_agg_address_person_location.address), IDENTITY(acp_geog_agg_location_history.addressLocation)) = acp_geog_agg_address.id'
|
||||
);
|
||||
|
||||
// and we do a join with units
|
||||
$qb->leftJoin(
|
||||
GeographicalUnit::class,
|
||||
'acp_geog_units',
|
||||
Join::WITH,
|
||||
'ST_CONTAINS(acp_geog_units.geom, acp_geog_agg_address.point) = TRUE'
|
||||
'acp_geog_agg_address.geographicalUnits',
|
||||
'acp_geog_units'
|
||||
);
|
||||
|
||||
$qb->andWhere($qb->expr()->eq('acp_geog_units.layer', ':acp_geog_unit_layer'));
|
||||
|
@@ -11,7 +11,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Export\Aggregator\PersonAggregators;
|
||||
|
||||
use Chill\MainBundle\Entity\GeographicalUnit;
|
||||
use Chill\MainBundle\Entity\GeographicalUnitLayer;
|
||||
use Chill\MainBundle\Export\AggregatorInterface;
|
||||
use Chill\MainBundle\Form\Type\PickRollingDateType;
|
||||
@@ -20,7 +19,6 @@ use Chill\MainBundle\Service\RollingDate\RollingDate;
|
||||
use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Doctrine\ORM\Query\Expr\Join;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use LogicException;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
@@ -54,7 +52,7 @@ class GeographicalUnitAggregator implements AggregatorInterface
|
||||
$qb
|
||||
->leftJoin('person.householdAddresses', 'person_geog_agg_current_household_address')
|
||||
->leftJoin('person_geog_agg_current_household_address.address', 'person_geog_agg_address')
|
||||
->leftJoin(GeographicalUnit::class, 'person_geog_agg_geog_unit', Join::WITH, 'ST_CONTAINS(person_geog_agg_geog_unit.geom, person_geog_agg_address.point) = TRUE')
|
||||
->leftJoin('person_geog_agg_address.geographicalUnits', 'person_geog_agg_geog_unit')
|
||||
->andWhere(
|
||||
$qb->expr()->orX(
|
||||
$qb->expr()->isNull('person_geog_agg_current_household_address'),
|
||||
|
Reference in New Issue
Block a user