diff --git a/judge/models/problem.py b/judge/models/problem.py index 3dac05b..4f7e545 100644 --- a/judge/models/problem.py +++ b/judge/models/problem.py @@ -251,11 +251,11 @@ class Problem(models.Model): q |= Q(testers=user.profile) queryset = queryset.filter(q) - return queryset.distinct() + return queryset @classmethod def get_public_problems(cls): - return cls.objects.filter(is_public=True, is_organization_private=False).defer('description').distinct() + return cls.objects.filter(is_public=True, is_organization_private=False).defer('description') def __str__(self): return self.name diff --git a/judge/models/profile.py b/judge/models/profile.py index b3c5fa0..d374738 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -143,7 +143,7 @@ class Profile(models.Model): .values_list('max_points', flat=True).filter(max_points__gt=0) ) extradata = ( - public_problems.filter(submission__user=self, submission__result='AC').values('id').count() + public_problems.filter(submission__user=self, submission__result='AC').values('id').distinct().count() ) bonus_function = settings.DMOJ_PP_BONUS_FUNCTION points = sum(data) diff --git a/judge/views/select2.py b/judge/views/select2.py index 0647f98..65249a5 100644 --- a/judge/views/select2.py +++ b/judge/views/select2.py @@ -55,7 +55,7 @@ class OrganizationSelect2View(Select2View): class ProblemSelect2View(Select2View): def get_queryset(self): return Problem.get_visible_problems(self.request.user) \ - .filter(Q(code__icontains=self.term) | Q(name__icontains=self.term)) + .filter(Q(code__icontains=self.term) | Q(name__icontains=self.term)).distinct() class ContestSelect2View(Select2View):