Optimize a query

This commit is contained in:
cuom1999 2023-01-27 17:58:44 -06:00
parent bd05ba6b78
commit 03455fca2c

View file

@ -588,11 +588,8 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
queryset = Problem.get_visible_problems(self.request.user) queryset = Problem.get_visible_problems(self.request.user)
queryset = queryset.select_related("group") queryset = queryset.select_related("group")
if self.profile is not None and self.hide_solved: if self.profile is not None and self.hide_solved:
queryset = queryset.exclude( solved_problems = self.get_completed_problems()
id__in=Submission.objects.filter( queryset = queryset.exclude(id__in=solved_problems)
user=self.profile, points=F("problem__points")
).values_list("problem__id", flat=True)
)
if not self.org_query and self.request.organization: if not self.org_query and self.request.organization:
self.org_query = [self.request.organization.id] self.org_query = [self.request.organization.id]
if self.org_query: if self.org_query: