Skip to content

Commit 6c3b7d1

Browse files
committed
Remove REST endpoints for the leaderboard
1 parent 30fc5e8 commit 6c3b7d1

File tree

5 files changed

+36
-165
lines changed

5 files changed

+36
-165
lines changed

stade/core/rest/__init__.py

Whitespace-only changes.

stade/core/rest/serializers.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

stade/core/rest/views.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

stade/core/tests/test_leaderboard.py

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ def task_with_submissions(db, approach_factory, submission_factory, task_factory
1414
- an approach where the most recent score is worse than a prior score (t1_a0)
1515
- a team with a better approach which has been rejected (t3)
1616
"""
17-
task = task_factory(challenge__name='Test Challenge', name='Test Task', scores_published=True)
17+
task = task_factory(
18+
challenge__name='Test Challenge', name='Test Task', scores_published=True, hidden=False
19+
)
1820

1921
teams = [
2022
team_factory(challenge=task.challenge),
@@ -66,47 +68,53 @@ def task_with_submissions(db, approach_factory, submission_factory, task_factory
6668

6769
@pytest.mark.django_db
6870
def test_leaderboard_by_approach(task_with_submissions, client):
69-
resp = client.get(f'/api/leaderboard/{task_with_submissions.id}/by-approach/')
71+
resp = client.get(
72+
f'/leaderboards/{task_with_submissions.challenge.slug}/?task={task_with_submissions.id}&group_by=approach'
73+
)
7074
assert resp.status_code == 200
7175

7276
# assert the by approach leaderboard looks like
7377
# team0 | approach0 | .95
7478
# team0 | approach1 | .80
7579
# team1 | approach1 | .78
7680
# team3 | approach1 | .60
77-
first, second, third, fourth = resp.json()['results']
78-
79-
assert first['team_name'] == 'team_0'
80-
assert first['approach_name'] == 'approach_0'
81-
assert first['overall_score'] == 0.95
82-
assert second['team_name'] == 'team_0'
83-
assert second['approach_name'] == 'approach_1'
84-
assert second['overall_score'] == 0.80
85-
assert third['team_name'] == 'team_1'
86-
assert third['approach_name'] == 'approach_0'
87-
assert third['overall_score'] == 0.78
88-
assert fourth['team_name'] == 'team_3'
89-
assert fourth['approach_name'] == 'approach_1'
90-
assert fourth['overall_score'] == 0.60
81+
submissions = resp.context['submissions']
82+
first, second, third, fourth = submissions[:4]
83+
84+
assert first.approach.team.name == 'team_0'
85+
assert first.approach.name == 'approach_0'
86+
assert first.overall_score == 0.95
87+
assert second.approach.team.name == 'team_0'
88+
assert second.approach.name == 'approach_1'
89+
assert second.overall_score == 0.80
90+
assert third.approach.team.name == 'team_1'
91+
assert third.approach.name == 'approach_0'
92+
assert third.overall_score == 0.78
93+
assert fourth.approach.team.name == 'team_3'
94+
assert fourth.approach.name == 'approach_1'
95+
assert fourth.overall_score == 0.60
9196

9297

9398
@pytest.mark.django_db
9499
def test_leaderboard_by_team(task_with_submissions, client):
95-
resp = client.get(f'/api/leaderboard/{task_with_submissions.id}/by-team/')
100+
resp = client.get(
101+
f'/leaderboards/{task_with_submissions.challenge.slug}/?task={task_with_submissions.id}&group_by=team'
102+
)
96103
assert resp.status_code == 200
97104

98105
# assert the by team leaderboard looks like
99106
# team4 | approach0 | .95
100107
# team5 | approach0 | .78
101108
# team7 | approach1 | .60
102-
first, second, third = resp.json()['results']
103-
104-
assert first['team_name'] == 'team_5'
105-
assert first['approach_name'] == 'approach_0'
106-
assert first['overall_score'] == 0.95
107-
assert second['team_name'] == 'team_6'
108-
assert second['approach_name'] == 'approach_0'
109-
assert second['overall_score'] == 0.78
110-
assert third['team_name'] == 'team_8'
111-
assert third['approach_name'] == 'approach_1'
112-
assert third['overall_score'] == 0.60
109+
submissions = resp.context['submissions']
110+
first, second, third = submissions[:3]
111+
112+
assert first.approach.team.name == 'team_5'
113+
assert first.approach.name == 'approach_0'
114+
assert first.overall_score == 0.95
115+
assert second.approach.team.name == 'team_6'
116+
assert second.approach.name == 'approach_0'
117+
assert second.overall_score == 0.78
118+
assert third.approach.team.name == 'team_8'
119+
assert third.approach.name == 'approach_1'
120+
assert third.overall_score == 0.60

stade/core/urls.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
from stade.core import views
66
from stade.core.models import Challenge
7-
from stade.core.rest import views as api_views
87

98

109
class ChallengeFromSlugConverter:
@@ -48,24 +47,6 @@ def to_url(self, value: str) -> str:
4847
views.request_submission_bundle,
4948
name='request-submission-bundle',
5049
),
51-
path('api/challenge/<int:challenge_id>/', api_views.challenge_detail, name='challenge-detail'),
52-
path(
53-
'api/leaderboard/<int:task_id>/by-approach/',
54-
api_views.leaderboard,
55-
{'cluster': 'approach'},
56-
name='leaderboard-by-approach',
57-
),
58-
path(
59-
'api/leaderboard/<int:task_id>/by-team/',
60-
api_views.leaderboard,
61-
{'cluster': 'team'},
62-
name='leaderboard-by-team',
63-
),
64-
path(
65-
'api/submission/<int:submission_id>/score/',
66-
api_views.submission_scores,
67-
name='submission-scores',
68-
),
6950
path('data/', TemplateView.as_view(template_name='data/base.html'), name='data'),
7051
path('stats/', views.stats, name='stats'),
7152
path('challenges/', views.challenges, name='challenges'),

0 commit comments

Comments
 (0)