Contest caching
This commit is contained in:
parent
86d1ff4eaa
commit
571596dcbf
9 changed files with 72 additions and 23 deletions
|
@ -198,7 +198,7 @@ class ContestList(
|
|||
queryset = (
|
||||
super(ContestList, self)
|
||||
.get_queryset()
|
||||
.prefetch_related("tags", "organizations", "authors", "curators", "testers")
|
||||
.prefetch_related("tags", "organizations")
|
||||
)
|
||||
|
||||
if self.request.GET.get("contest"):
|
||||
|
@ -248,9 +248,6 @@ class ContestList(
|
|||
virtual=0, user=self.request.profile, contest_id__in=present
|
||||
)
|
||||
.select_related("contest")
|
||||
.prefetch_related(
|
||||
"contest__authors", "contest__curators", "contest__testers"
|
||||
)
|
||||
.annotate(key=F("contest__key"))
|
||||
):
|
||||
if not participation.ended:
|
||||
|
|
|
@ -478,6 +478,9 @@ class OrganizationSubmissions(
|
|||
),
|
||||
)
|
||||
|
||||
def get_title(self):
|
||||
return _("Submissions in") + f" {self.organization}"
|
||||
|
||||
|
||||
class OrganizationMembershipChange(
|
||||
LoginRequiredMixin, OrganizationMixin, SingleObjectMixin, View
|
||||
|
@ -983,6 +986,18 @@ class EditOrganizationContest(
|
|||
)
|
||||
):
|
||||
transaction.on_commit(rescore_contest.s(self.object.key).delay)
|
||||
|
||||
if any(
|
||||
f in form.changed_data
|
||||
for f in (
|
||||
"authors",
|
||||
"curators",
|
||||
"testers",
|
||||
)
|
||||
):
|
||||
Contest._author_ids.dirty(self.object)
|
||||
Contest._curator_ids.dirty(self.object)
|
||||
Contest._tester_ids.dirty(self.object)
|
||||
return res
|
||||
|
||||
def get_problem_formset(self, post=False):
|
||||
|
@ -1075,7 +1090,7 @@ class EditOrganizationBlog(
|
|||
if self.organization not in self.blog.organizations.all():
|
||||
raise Exception("This blog does not belong to this organization")
|
||||
if (
|
||||
self.request.profile not in self.blog.authors.all()
|
||||
self.request.profile.id not in self.blog.get_authors()
|
||||
and not self.can_edit_organization(self.organization)
|
||||
):
|
||||
raise Exception("Not allowed to edit this blog")
|
||||
|
|
|
@ -64,6 +64,7 @@ from judge.models import (
|
|||
Organization,
|
||||
Profile,
|
||||
LanguageTemplate,
|
||||
Contest,
|
||||
)
|
||||
from judge.pdf_problems import DefaultPdfMaker, HAS_PDF
|
||||
from judge.utils.diggpaginator import DiggPaginator
|
||||
|
@ -587,7 +588,7 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
i
|
||||
for i in query
|
||||
if i in self.profile.organizations.values_list("id", flat=True)
|
||||
]
|
||||
][:3]
|
||||
|
||||
def get_normal_queryset(self):
|
||||
queryset = Problem.get_visible_problems(self.request.user)
|
||||
|
@ -599,9 +600,14 @@ class ProblemList(QueryStringSortMixin, TitleMixin, SolvedProblemMixin, ListView
|
|||
self.org_query = [self.request.organization.id]
|
||||
if self.org_query:
|
||||
self.org_query = self.get_org_query(self.org_query)
|
||||
contest_problems = (
|
||||
Contest.objects.filter(organizations__in=self.org_query)
|
||||
.select_related("problems")
|
||||
.values_list("contest_problems__problem__id")
|
||||
.distinct()
|
||||
)
|
||||
queryset = queryset.filter(
|
||||
Q(organizations__in=self.org_query)
|
||||
| Q(contests__contest__organizations__in=self.org_query)
|
||||
Q(organizations__in=self.org_query) | Q(id__in=contest_problems)
|
||||
)
|
||||
if self.author_query:
|
||||
queryset = queryset.filter(authors__in=self.author_query)
|
||||
|
|
|
@ -52,7 +52,7 @@ from judge.utils.timedelta import nice_repr
|
|||
def submission_related(queryset):
|
||||
return queryset.select_related("user", "problem", "language").only(
|
||||
"id",
|
||||
"user_id",
|
||||
"user__id",
|
||||
"problem__name",
|
||||
"problem__code",
|
||||
"problem__is_public",
|
||||
|
@ -67,7 +67,8 @@ def submission_related(queryset):
|
|||
"case_points",
|
||||
"case_total",
|
||||
"current_testcase",
|
||||
"contest_object",
|
||||
"contest_object__key",
|
||||
"contest_object__name",
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue