From 7977380c163ec984c6e4ce0973e23b1c43251714 Mon Sep 17 00:00:00 2001 From: Harkamal Randhawa Date: Mon, 20 Apr 2026 08:24:28 -0600 Subject: [PATCH] auto-complete scheduled appointments --- .../petshop/backend/repository/AppointmentRepository.java | 2 +- .../com/petshop/backend/service/AppointmentService.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/petshop/backend/repository/AppointmentRepository.java b/backend/src/main/java/com/petshop/backend/repository/AppointmentRepository.java index b23b1902..774c1427 100644 --- a/backend/src/main/java/com/petshop/backend/repository/AppointmentRepository.java +++ b/backend/src/main/java/com/petshop/backend/repository/AppointmentRepository.java @@ -48,7 +48,7 @@ public interface AppointmentRepository extends JpaRepository @Query("SELECT a FROM Appointment a JOIN FETCH a.service WHERE a.employee.id IN :employeeIds AND a.appointmentDate = :date AND LOWER(a.appointmentStatus) NOT IN ('cancelled', 'missed')") List findByEmployeeIdInAndAppointmentDate(@Param("employeeIds") List employeeIds, @Param("date") LocalDate date); - @Query("SELECT a FROM Appointment a WHERE (a.appointmentDate < :currentDate OR (a.appointmentDate = :currentDate AND a.appointmentTime < :currentTime)) AND LOWER(a.appointmentStatus) = 'booked'") + @Query("SELECT a FROM Appointment a WHERE (a.appointmentDate < :currentDate OR (a.appointmentDate = :currentDate AND a.appointmentTime < :currentTime)) AND LOWER(a.appointmentStatus) IN ('booked', 'scheduled')") List findPastBookedAppointments(@Param("currentDate") LocalDate currentDate, @Param("currentTime") LocalTime currentTime); List findByPet_Id(Long petId); diff --git a/backend/src/main/java/com/petshop/backend/service/AppointmentService.java b/backend/src/main/java/com/petshop/backend/service/AppointmentService.java index 832dc12e..048bdc37 100644 --- a/backend/src/main/java/com/petshop/backend/service/AppointmentService.java +++ b/backend/src/main/java/com/petshop/backend/service/AppointmentService.java @@ -279,8 +279,12 @@ public class AppointmentService { LocalDate tomorrow = currentDate.plusDays(1); - List tomorrowAppointments = appointmentRepository + List tomorrowBooked = appointmentRepository .findByAppointmentDateAndAppointmentStatusIgnoreCase(tomorrow, "Booked"); + List tomorrowScheduled = appointmentRepository + .findByAppointmentDateAndAppointmentStatusIgnoreCase(tomorrow, "Scheduled"); + List tomorrowAppointments = new java.util.ArrayList<>(tomorrowBooked); + tomorrowAppointments.addAll(tomorrowScheduled); for (Appointment appointment : tomorrowAppointments) { eventPublisher.publishEvent(new AppointmentReminderEvent(appointment.getAppointmentId())); }