diff --git a/api/app/services/availability_service.py b/api/app/services/availability_service.py index a05b43fd4..86d63f24e 100644 --- a/api/app/services/availability_service.py +++ b/api/app/services/availability_service.py @@ -76,6 +76,9 @@ def get_available_slots(office: Office, days: [datetime], format_time: bool = Tr end_time = add_delta_to_time(end_time, minutes=appointment_duration, timezone=office.timezone.timezone_name) + # Sort the slot by time for the day + available_slots_per_day[formatted_date].sort(key=lambda x: x['start_time']) + # Check if the slots are already booked for actual_slot in available_slots_per_day[formatted_date]: for booked_slot in grouped_appointments.get(formatted_date, []): @@ -134,7 +137,6 @@ def group_appointments(appointments, timezone: str): }) return filtered_appointments - @staticmethod def prune_appointments(available_slots_per_day: Dict): for key, slots in available_slots_per_day.items():