From 84ef4d20b82ea945862200c65ef43309a3dd2a21 Mon Sep 17 00:00:00 2001 From: Radu Pogonariu Date: Sat, 30 Jan 2021 21:01:56 +0100 Subject: [PATCH 1/2] Expose participation start and end times through API; fixes #1586 --- judge/views/api/api_v2.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/judge/views/api/api_v2.py b/judge/views/api/api_v2.py index 6b998bf87..ec6d0b424 100644 --- a/judge/views/api/api_v2.py +++ b/judge/views/api/api_v2.py @@ -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, @@ -307,6 +311,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, @@ -354,6 +360,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', @@ -366,6 +376,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, From ce8091b4303442f3986100bad12537e612a846f7 Mon Sep 17 00:00:00 2001 From: Le Bao Hiep Date: Tue, 5 Sep 2023 22:51:27 +0700 Subject: [PATCH 2/2] Fix `hidden_scoreboard` field in `APIContestDetail` --- judge/views/api/api_v2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/judge/views/api/api_v2.py b/judge/views/api/api_v2.py index ec6d0b424..771647f99 100644 --- a/judge/views/api/api_v2.py +++ b/judge/views/api/api_v2.py @@ -285,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(