Skip to content

Commit

Permalink
Expose participation start and end times through API; fixes #1586
Browse files Browse the repository at this point in the history
  • Loading branch information
WallE256 authored and kiritofeng committed Feb 26, 2021
1 parent 26cbe26 commit 0c009fa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions judge/views/api/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,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 Down Expand Up @@ -257,6 +261,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 @@ -303,6 +309,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 @@ -315,6 +325,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

0 comments on commit 0c009fa

Please sign in to comment.