Some more optimizations
This commit is contained in:
parent
a9dc97a46d
commit
3f6841932b
9 changed files with 65 additions and 44 deletions
|
@ -482,13 +482,10 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
padding=2,
|
||||
orphans=orphans,
|
||||
allow_empty_first_page=allow_empty_first_page,
|
||||
count=queryset.values("pk").count() if not self.in_contest else None,
|
||||
**kwargs
|
||||
)
|
||||
if not self.in_contest:
|
||||
# Get the number of pages and then add in this magic.
|
||||
# noinspection PyStatementEffect
|
||||
paginator.num_pages
|
||||
|
||||
queryset = queryset.add_i18n_name(self.request.LANGUAGE_CODE)
|
||||
sort_key = self.order.lstrip("-")
|
||||
if sort_key in self.sql_sort:
|
||||
|
@ -670,8 +667,12 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
|
||||
if self.request.profile:
|
||||
context["organizations"] = self.request.profile.organizations.all()
|
||||
all_authors_ids = set(Problem.objects.values_list("authors", flat=True))
|
||||
context["all_authors"] = Profile.objects.filter(id__in=all_authors_ids)
|
||||
all_authors_ids = Problem.objects.values_list("authors", flat=True)
|
||||
context["all_authors"] = (
|
||||
Profile.objects.filter(id__in=all_authors_ids)
|
||||
.select_related("user")
|
||||
.values("id", "user__username")
|
||||
)
|
||||
context["category"] = self.category
|
||||
context["categories"] = ProblemGroup.objects.all()
|
||||
if self.show_types:
|
||||
|
|
|
@ -41,9 +41,7 @@ from judge.models import ProblemTranslation
|
|||
from judge.models import Profile
|
||||
from judge.models import Submission
|
||||
from judge.utils.problems import get_result_data
|
||||
from judge.utils.problems import user_authored_ids
|
||||
from judge.utils.problems import user_completed_ids
|
||||
from judge.utils.problems import user_editable_ids
|
||||
from judge.utils.problems import user_completed_ids, user_editable_ids, user_tester_ids
|
||||
from judge.utils.problem_data import get_problem_case
|
||||
from judge.utils.raw_sql import join_sql_subquery, use_straight_join
|
||||
from judge.utils.views import DiggPaginatorMixin
|
||||
|
@ -476,12 +474,12 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
|
|||
context["completed_problem_ids"] = (
|
||||
user_completed_ids(self.request.profile) if authenticated else []
|
||||
)
|
||||
context["authored_problem_ids"] = (
|
||||
user_authored_ids(self.request.profile) if authenticated else []
|
||||
)
|
||||
context["editable_problem_ids"] = (
|
||||
user_editable_ids(self.request.profile) if authenticated else []
|
||||
)
|
||||
context["tester_problem_ids"] = (
|
||||
user_tester_ids(self.request.profile) if authenticated else []
|
||||
)
|
||||
|
||||
context["all_languages"] = Language.objects.all().values_list("key", "name")
|
||||
context["selected_languages"] = self.selected_languages
|
||||
|
@ -769,15 +767,15 @@ def single_submission(request, submission_id, show_problem=True):
|
|||
"submission/row.html",
|
||||
{
|
||||
"submission": submission,
|
||||
"authored_problem_ids": user_authored_ids(request.profile)
|
||||
if authenticated
|
||||
else [],
|
||||
"completed_problem_ids": user_completed_ids(request.profile)
|
||||
if authenticated
|
||||
else [],
|
||||
"editable_problem_ids": user_editable_ids(request.profile)
|
||||
if authenticated
|
||||
else [],
|
||||
"tester_problem_ids": user_tester_ids(request.profile)
|
||||
if authenticated
|
||||
else [],
|
||||
"show_problem": show_problem,
|
||||
"problem_name": show_problem
|
||||
and submission.problem.translated_name(request.LANGUAGE_CODE),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue