Skip to content

Commit

Permalink
Merge pull request #1645 from codalab/count_fix
Browse files Browse the repository at this point in the history
URGENT - removed count from competition query to fix the codabench
  • Loading branch information
Didayolo authored Nov 5, 2024
2 parents c2cd638 + 8fe4274 commit 84b3946
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/apps/api/views/competitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.http import HttpResponse
from tempfile import SpooledTemporaryFile
from django.db import IntegrityError
from django.db.models import Subquery, OuterRef, Count, Q, F, Case, When
from django.db.models import Subquery, OuterRef, Count, Q, F
from django_filters.rest_framework import DjangoFilterBackend
from drf_yasg.utils import swagger_auto_schema, no_body
from rest_framework import status
Expand Down Expand Up @@ -168,13 +168,13 @@ def get_queryset(self):
'phases__leaderboard__columns',
'collaborators',
)
qs = qs.annotate(participant_count=Count(F('participants'), distinct=True))
qs = qs.annotate(submission_count=Count(
# Filtering out children submissions so we only count distinct submissions
Case(
When(phases__submissions__parent__isnull=True, then='phases__submissions__pk')
), distinct=True)
)
# qs = qs.annotate(participant_count=Count(F('participants'), distinct=True))
# qs = qs.annotate(submission_count=Count(
# # Filtering out children submissions so we only count distinct submissions
# Case(
# When(phases__submissions__parent__isnull=True, then='phases__submissions__pk')
# ), distinct=True)
# )

# search_query is true when called from searchbar
if search_query:
Expand Down

0 comments on commit 84b3946

Please sign in to comment.