2026-06-19 01:04:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Repository;
|
|
|
|
|
|
|
|
|
|
use App\Entity\Bucket;
|
2026-06-20 00:28:29 +02:00
|
|
|
use App\Entity\Scenario;
|
|
|
|
|
use App\Enum\BucketType;
|
2026-06-19 01:04:38 +02:00
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
|
|
|
use Doctrine\Persistence\ManagerRegistry;
|
2026-06-20 00:28:29 +02:00
|
|
|
use Symfony\Component\Uid\UuidV7;
|
2026-06-19 01:04:38 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @extends ServiceEntityRepository<Bucket>
|
|
|
|
|
*/
|
|
|
|
|
class BucketRepository extends ServiceEntityRepository
|
|
|
|
|
{
|
|
|
|
|
public function __construct(ManagerRegistry $registry)
|
|
|
|
|
{
|
|
|
|
|
parent::__construct($registry, Bucket::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-20 00:28:29 +02:00
|
|
|
public function countOverflowBucketsForScenario(Scenario $scenario, ?UuidV7 $excludeId = null): int
|
|
|
|
|
{
|
|
|
|
|
$qb = $this->createQueryBuilder('b')
|
|
|
|
|
->select('COUNT(b.id)')
|
|
|
|
|
->andWhere('b.scenario = :scenario')
|
|
|
|
|
->andWhere('b.type = :overflow')
|
|
|
|
|
->setParameter('scenario', $scenario)
|
|
|
|
|
->setParameter('overflow', BucketType::OVERFLOW);
|
|
|
|
|
|
|
|
|
|
if (null !== $excludeId) {
|
|
|
|
|
$qb->andWhere('b.id != :excludeId')
|
|
|
|
|
->setParameter('excludeId', $excludeId, 'uuid');
|
|
|
|
|
}
|
2026-06-19 01:04:38 +02:00
|
|
|
|
2026-06-20 00:28:29 +02:00
|
|
|
return (int) $qb->getQuery()->getSingleScalarResult();
|
|
|
|
|
}
|
2026-06-19 01:04:38 +02:00
|
|
|
}
|