Move the query to calculate the max subscriber ID to SubscribersRepository

[MAILPOET-4344]
This commit is contained in:
Rodrigo Primo
2022-07-28 15:42:11 -03:00
committed by Veljko V
parent 0f7a3c3e00
commit af396021db
3 changed files with 27 additions and 17 deletions

View File

@ -362,4 +362,14 @@ class SubscribersRepository extends Repository {
->getQuery()
->getArrayResult();
}
public function getMaxSubscriberId(): int {
$maxSubscriberId = $this->entityManager->createQueryBuilder()
->select('MAX(s.id)')
->from(SubscriberEntity::class, 's')
->getQuery()
->getSingleScalarResult();
return is_int($maxSubscriberId) ? $maxSubscriberId : 0;
}
}