Skip to content

Commit

Permalink
Fix possible error when trying to prepare grid for empty schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmitka committed Sep 12, 2023
1 parent 84e439e commit 0e6f299
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions program/schedule_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_from_slots(cls, slots: Iterable[models.Slot]) -> "ScheduleGrid":

# Populate the rows with items.
last_item: ScheduleItem | None = None
last_row_time = max(rows.keys())
last_row_time = max(rows.keys()) if rows else None
for slot in slots:
# If the last item was the same event, but in a different room,
# expand the previous slot to the current room.
Expand All @@ -68,7 +68,7 @@ def create_from_slots(cls, slots: Iterable[models.Slot]) -> "ScheduleGrid":

item_row = rows[slot.start]

if slot.end > last_row_time:
if last_row_time and slot.end > last_row_time:
end_row = rows.get(last_row_time)
grid_row_end = end_row.offset + 1
else:
Expand Down

0 comments on commit 0e6f299

Please sign in to comment.