From ab5ccd61686b55442ffdd24eeb318f5393f46660 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Tue, 20 Jun 2023 04:39:15 +0500 Subject: [PATCH 1/2] number of entries fixed --- src/apps/api/views/competitions.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index d27a3fe5e..30f5a36c7 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -520,7 +520,15 @@ def get_leaderboard(self, request, pk): for submission in query['submissions']: # count number of entries/number of submissions for the owner of this submission for this phase - num_entries = Submission.objects.filter(owner__username=submission['owner'], phase=phase).count() + # count all submissions with no parent and count all parents without counting the children + num_entries = Submission.objects.filter( + Q(owner__username=submission['owner']) | Q(parent__owner__username=submission['owner']), + phase=phase, + ).exclude( + parent__isnull=False + ).count() + + print(num_entries) # get date of last submission by the owner of this submission for this phase last_entry_date = Submission.objects.filter(owner__username=submission['owner'], phase=phase)\ From 8e8335038f6546cd2efa8049df3a9318b4df9646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Pav=C3=A3o?= Date: Tue, 20 Jun 2023 11:45:30 +0200 Subject: [PATCH 2/2] Remove print --- src/apps/api/views/competitions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/apps/api/views/competitions.py b/src/apps/api/views/competitions.py index 30f5a36c7..5c910b588 100644 --- a/src/apps/api/views/competitions.py +++ b/src/apps/api/views/competitions.py @@ -518,7 +518,6 @@ def get_leaderboard(self, request, pk): columns = [col for col in query['columns']] submissions_keys = {} 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 num_entries = Submission.objects.filter( @@ -528,8 +527,6 @@ def get_leaderboard(self, request, pk): parent__isnull=False ).count() - print(num_entries) - # get date of last submission by the owner of this submission for this phase last_entry_date = Submission.objects.filter(owner__username=submission['owner'], phase=phase)\ .values('created_when')\