mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
DX: improve performance for counting feature linked to person
This commit is contained in:
@@ -32,6 +32,16 @@ class ResidentialAddressRepository extends ServiceEntityRepository
|
||||
parent::__construct($registry, ResidentialAddress::class);
|
||||
}
|
||||
|
||||
public function countByPerson(Person $person): int
|
||||
{
|
||||
return $this->createQueryBuilder('ra')
|
||||
->select('COUNT(ra)')
|
||||
->where('ra.person = :person')
|
||||
->setParameter('person', $person)
|
||||
->getQuery()
|
||||
->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQueryFindCurrentResidentialAddresses(Person $person, ?DateTimeImmutable $at = null): QueryBuilder
|
||||
{
|
||||
$date = null === $at ? new DateTimeImmutable('today') : $at;
|
||||
|
Reference in New Issue
Block a user