Update geographical unit filter for period's location

The geographical unit filter in the accompanying course filters now takes the period's location on the address into account. This enhancement was achieved by modifying the GeographicalUnitStatFilter class. As a result, the "filter accompanying period by geographical unit" option provides more accurate data.
This commit is contained in:
Julien Fastré 2024-04-29 11:39:46 +02:00
parent 4c05d1e026
commit c773f9c6db
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
2 changed files with 16 additions and 6 deletions

View File

@ -0,0 +1,6 @@
kind: Fixed
body: Allow the filter "filter accompanying period by geographical unit" to take period's
location on address into account
time: 2024-04-29T11:38:04.966027861+02:00
custom:
Issue: "275"

View File

@ -33,8 +33,12 @@ use Symfony\Component\Form\FormBuilderInterface;
*/ */
class GeographicalUnitStatFilter implements FilterInterface class GeographicalUnitStatFilter implements FilterInterface
{ {
public function __construct(private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository, private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository, private readonly TranslatableStringHelperInterface $translatableStringHelper, private readonly RollingDateConverterInterface $rollingDateConverter) public function __construct(
{ private readonly GeographicalUnitRepositoryInterface $geographicalUnitRepository,
private readonly GeographicalUnitLayerRepositoryInterface $geographicalUnitLayerRepository,
private readonly TranslatableStringHelperInterface $translatableStringHelper,
private readonly RollingDateConverterInterface $rollingDateConverter
) {
} }
public function addRole(): ?string public function addRole(): ?string
@ -50,6 +54,10 @@ class GeographicalUnitStatFilter implements FilterInterface
FROM '.AccompanyingPeriod\AccompanyingPeriodLocationHistory::class.' acp_geog_filter_location_history FROM '.AccompanyingPeriod\AccompanyingPeriodLocationHistory::class.' acp_geog_filter_location_history
LEFT JOIN '.PersonHouseholdAddress::class.' acp_geog_filter_address_person_location LEFT JOIN '.PersonHouseholdAddress::class.' acp_geog_filter_address_person_location
WITH IDENTITY(acp_geog_filter_location_history.personLocation) = IDENTITY(acp_geog_filter_address_person_location.person) WITH IDENTITY(acp_geog_filter_location_history.personLocation) = IDENTITY(acp_geog_filter_address_person_location.person)
AND
(acp_geog_filter_address_person_location.validFrom < :acp_geog_filter_date AND (
acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo > :acp_geog_filter_date
))
LEFT JOIN '.Address::class.' acp_geog_filter_address LEFT JOIN '.Address::class.' acp_geog_filter_address
WITH COALESCE(IDENTITY(acp_geog_filter_address_person_location.address), IDENTITY(acp_geog_filter_location_history.addressLocation)) = acp_geog_filter_address.id WITH COALESCE(IDENTITY(acp_geog_filter_address_person_location.address), IDENTITY(acp_geog_filter_location_history.addressLocation)) = acp_geog_filter_address.id
LEFT JOIN acp_geog_filter_address.geographicalUnits acp_geog_filter_units LEFT JOIN acp_geog_filter_address.geographicalUnits acp_geog_filter_units
@ -57,10 +65,6 @@ class GeographicalUnitStatFilter implements FilterInterface
(acp_geog_filter_location_history.startDate <= :acp_geog_filter_date AND ( (acp_geog_filter_location_history.startDate <= :acp_geog_filter_date AND (
acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate > :acp_geog_filter_date acp_geog_filter_location_history.endDate IS NULL OR acp_geog_filter_location_history.endDate > :acp_geog_filter_date
)) ))
AND
(acp_geog_filter_address_person_location.validFrom < :acp_geog_filter_date AND (
acp_geog_filter_address_person_location.validTo IS NULL OR acp_geog_filter_address_person_location.validTo > :acp_geog_filter_date
))
AND acp_geog_filter_units IN (:acp_geog_filter_units) AND acp_geog_filter_units IN (:acp_geog_filter_units)
AND acp_geog_filter_location_history.period = acp.id AND acp_geog_filter_location_history.period = acp.id
'; ';