Skip to content

Commit

Permalink
fix overcrowded view see #631
Browse files Browse the repository at this point in the history
to use itertools.groupby() the iterable needs to be sorted
see https://docs.python.org/3/library/itertools.html#itertools.groupby
  • Loading branch information
jnsga committed Jan 21, 2024
1 parent 4b8eb3c commit 6da53eb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pycroft/lib/facilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_overcrowded_rooms(building_id: int = None) -> dict[int, list[User]]:
)

users = session.session.scalars(stmt).unique().all()
users = sorted(users, key=lambda u: u.room.id)
return {k: list(v) for k, v in groupby(users, lambda u: u.room.id)}


Expand Down

0 comments on commit 6da53eb

Please sign in to comment.