From 14ac01d597d4b3fd949e5ebf26a06e8aadabd1c2 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Mon, 15 Jun 2026 17:54:18 +0330 Subject: [PATCH] feat(appointment): treat expired pending bookings as free in isSlotTaken A slot is taken only if confirmed, or pending with a still-valid lock (expires_at null or in the future). An expired pending booking no longer blocks the slot even before the cron flips it to expired. Co-Authored-By: Claude Opus 4.8 --- src/Appointment/Repository/AppointmentRepository.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Appointment/Repository/AppointmentRepository.php b/src/Appointment/Repository/AppointmentRepository.php index 7b12012d..13ca2f0d 100644 --- a/src/Appointment/Repository/AppointmentRepository.php +++ b/src/Appointment/Repository/AppointmentRepository.php @@ -27,11 +27,15 @@ class AppointmentRepository extends ServiceEntityRepository $qb = $this->createQueryBuilder('a') ->select('COUNT(a.id)') ->where('a.doctor = :doctor') - ->andWhere('a.status IN (:activeStatuses)') ->andWhere('a.slotStart < :slotEnd') ->andWhere('a.slotEnd > :slotStart') + ->andWhere( + 'a.status = :confirmed OR (a.status = :pending AND (a.expiresAt IS NULL OR a.expiresAt > :now))' + ) ->setParameter('doctor', $doctor) - ->setParameter('activeStatuses', [Appointment::STATUS_PENDING, Appointment::STATUS_CONFIRMED]) + ->setParameter('confirmed', Appointment::STATUS_CONFIRMED) + ->setParameter('pending', Appointment::STATUS_PENDING) + ->setParameter('now', time()) ->setParameter('slotStart', $slotStart) ->setParameter('slotEnd', $slotEnd);