Skip to content
Open
4 changes: 3 additions & 1 deletion api/app/services/availability_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't hurt, but I think the query is getting all appointments by time and the time slot calculation starts with ascending order of slots.

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, []):
Expand Down Expand Up @@ -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():
Expand Down