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

Leaderboard number of entries #1330

Merged
merged 1 commit into from
Feb 15, 2024
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
12 changes: 9 additions & 3 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,12 +704,18 @@ def get_leaderboard(self, request, pk):
submission_detailed_results = {}
for submission in query['submissions']:
# count number of entries/number of submissions for the owner of this submission for this phase
# count all submissions with no parent and count all parents without counting the children
# count all submissions except:
# - child submissions (submissions who has a parent i.e. parent field is not null)
# - Failed submissions
# - Cancelled submissions
num_entries = Submission.objects.filter(
Q(owner__username=submission['owner']) | Q(parent__owner__username=submission['owner']),
Q(owner__username=submission['owner']) |
Q(parent__owner__username=submission['owner']),
phase=phase,
).exclude(
parent__isnull=False
Q(status=Submission.FAILED) |
Q(status=Submission.CANCELLED) |
Q(parent__isnull=False)
).count()

submission_key = f"{submission['owner']}{submission['parent'] or submission['id']}"
Expand Down