Skip to content

Commit

Permalink
Fix Queue Sort Order (#640)
Browse files Browse the repository at this point in the history
* Added sort to queued tickets by start time

* Fix sorted order for students view
  • Loading branch information
ajaygandecha authored Nov 11, 2024
1 parent 135fde2 commit 6a19b88
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions backend/services/office_hours/office_hours.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,16 @@ def get_office_hour_get_help_overview(
active_ticket = active_tickets[0] if len(active_tickets) > 0 else None

# Find queue position
queue_tickets = [
ticket
for ticket in queue_entity.tickets
if ticket.state == TicketState.QUEUED
]
queue_tickets = (
sorted(
[
ticket
for ticket in queue_entity.tickets
if ticket.state == TicketState.QUEUED
],
key=lambda ticket: ticket.created_at,
),
)

queue_position = (
queue_tickets.index(active_ticket) + 1
Expand Down Expand Up @@ -230,7 +235,10 @@ def _to_oh_queue_overview(
other_called=[
self._to_oh_ticket_overview(ticket) for ticket in called_tickets
],
queue=[self._to_oh_ticket_overview(ticket) for ticket in queued_tickets],
queue=sorted(
[self._to_oh_ticket_overview(ticket) for ticket in queued_tickets],
key=lambda ticket: ticket.created_at,
),
personal_tickets_called=len(personal_completed_tickets),
average_minutes=personal_average_minutes,
total_tickets_called=len(completed_tickets),
Expand Down

0 comments on commit 6a19b88

Please sign in to comment.