Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update api_v2.py to match upstream #323

Merged
merged 2 commits into from
Sep 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion judge/views/api/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ def get_object_data(self, contest):
.order_by('-score', 'cumtime', 'tiebreaker')
)

# Setting contest attribute to reduce db queries in .start and .end_time
for participation in participations:
participation.contest = contest

return {
'key': contest.key,
'name': contest.name,
Expand All @@ -281,7 +285,8 @@ def get_object_data(self, contest):
'rating_floor': contest.rating_floor,
'rating_ceiling': contest.rating_ceiling,
'hidden_scoreboard': contest.scoreboard_visibility in (contest.SCOREBOARD_AFTER_CONTEST,
contest.SCOREBOARD_AFTER_PARTICIPATION),
contest.SCOREBOARD_AFTER_PARTICIPATION,
contest.SCOREBOARD_HIDDEN),
'scoreboard_visibility': contest.scoreboard_visibility,
'is_organization_private': contest.is_organization_private,
'organizations': list(
Expand All @@ -307,6 +312,8 @@ def get_object_data(self, contest):
'rankings': [
{
'user': participation.username,
'start_time': participation.start.isoformat(),
'end_time': participation.end_time.isoformat(),
'score': participation.score,
'cumulative_time': participation.cumtime,
'tiebreaker': participation.tiebreaker,
Expand Down Expand Up @@ -354,6 +361,10 @@ def get_unfiltered_queryset(self):
.only(
'user__user__username',
'contest__key',
'contest__start_time',
'contest__end_time',
'contest__time_limit',
'real_start',
'score',
'cumtime',
'tiebreaker',
Expand All @@ -366,6 +377,8 @@ def get_object_data(self, participation):
return {
'user': participation.user.username,
'contest': participation.contest.key,
'start_time': participation.start.isoformat(),
'end_time': participation.end_time.isoformat(),
'score': participation.score,
'cumulative_time': participation.cumtime,
'tiebreaker': participation.tiebreaker,
Expand Down