opus-magnum results view

This commit is contained in:
2026-05-10 02:38:56 +02:00
parent fa53d74295
commit d2a9dbe4a4
3 changed files with 280 additions and 5 deletions
+3 -1
View File
@@ -26,7 +26,9 @@ def results(request: HttpRequest) -> dict:
ranking = {}
for puzzle_id, responses in responses_by_puzzleid.items():
ranking[puzzle_id] = sorted(responses, key=lambda x: x.rank_points)
ranking[puzzle_id] = sorted(
responses, key=lambda x: (x.rank_points is None, x.rank_points or 0)
)
return {
"users": CustomUser.objects.filter(pk__in=responses_by_userid.keys()),
+6 -1
View File
@@ -30,8 +30,13 @@ class PuzzleResponseRankingOut(ModelSchema):
return obj.submission.user.id
class UserDisplayOut(Schema):
id: int
username: str
class RankingSchema(Schema):
users: list[UserInfoOut]
users: list[UserDisplayOut]
puzzles: list[SteamCollectionItemOut]
responses_by_userid: dict[int, list[PuzzleResponseRankingOut]]
ranking_by_puzzle: dict[int, list[PuzzleResponseRankingOut]]