Feature: Store location of each address contained in geographical units in a materialized view

This commit is contained in:
2022-11-14 12:07:52 +01:00
parent ec9555ec84
commit d3ba11f521
2 changed files with 72 additions and 1 deletions

View File

@@ -15,6 +15,8 @@ use Chill\MainBundle\Doctrine\Model\Point;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
@@ -97,6 +99,23 @@ class Address
*/
private $floor;
/**
* List of geographical units and addresses.
*
* This list is computed by a materialized view. It won't be populated until a refresh is done
* on the materialized view.
*
* @var Collection<int, GeographicalUnit>|GeographicalUnit[]
* @readonly
* @ORM\ManyToMany(targetEntity=GeographicalUnit::class)
* @ORM\JoinTable(
* name="view_chill_main_address_geographical_unit",
* joinColumns={@ORM\JoinColumn(name="address_id")},
* inverseJoinColumns={@ORM\JoinColumn(name="geographical_unit_id")}
* )
*/
private Collection $geographicalUnits;
/**
* @var int
*
@@ -104,8 +123,9 @@ class Address
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"write"})
* @readonly
*/
private $id;
private ?int $id = null;
/**
* True if the address is a "no address", aka homeless person, ...
@@ -190,6 +210,7 @@ class Address
public function __construct()
{
$this->validFrom = new DateTime();
$this->geographicalUnits = new ArrayCollection();
}
public static function createFromAddress(Address $original): Address
@@ -273,6 +294,14 @@ class Address
return $this->floor;
}
/**
* @return Collection<int, GeographicalUnit>|GeographicalUnit[]
*/
public function getGeographicalUnits(): Collection
{
return $this->geographicalUnits;
}
/**
* Get id.
*