Cache prefetch
This commit is contained in:
parent
c2f6dba462
commit
2831a24b90
6 changed files with 70 additions and 34 deletions
|
@ -470,6 +470,7 @@ class SubmissionsListBase(DiggPaginatorMixin, TitleMixin, ListView):
|
|||
if context["in_hidden_subtasks_contest"]:
|
||||
for submission in context["submissions"]:
|
||||
self.modify_attrs(submission)
|
||||
|
||||
return context
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
|
|
|
@ -457,14 +457,13 @@ class UserList(QueryStringSortMixin, InfinitePaginationMixin, TitleMixin, ListVi
|
|||
queryset = (
|
||||
Profile.objects.filter(is_unlisted=False)
|
||||
.order_by(self.order, "id")
|
||||
.select_related("user")
|
||||
.only(
|
||||
"display_rank",
|
||||
"user__username",
|
||||
"points",
|
||||
"rating",
|
||||
"performance_points",
|
||||
"problem_count",
|
||||
"about",
|
||||
)
|
||||
)
|
||||
if self.request.organization:
|
||||
|
@ -472,11 +471,11 @@ class UserList(QueryStringSortMixin, InfinitePaginationMixin, TitleMixin, ListVi
|
|||
if (self.request.GET.get("friend") == "true") and self.request.profile:
|
||||
queryset = self.filter_friend_queryset(queryset)
|
||||
self.filter_friend = True
|
||||
|
||||
return queryset
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(UserList, self).get_context_data(**kwargs)
|
||||
Profile.prefetch_profile_cache([u.id for u in context["users"]])
|
||||
context["users"] = ranker(
|
||||
context["users"], rank=self.paginate_by * (context["page_obj"].number - 1)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue