Fix score issue

This commit is contained in:
cuom1999 2021-05-25 16:01:23 -05:00
parent 6c66f96e9d
commit 52ba13fd51
3 changed files with 4 additions and 4 deletions

View file

@ -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

View file

@ -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)

View file

@ -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):