Raid detail: Prefetch pseudo no-response objects; 162 queries -> 18.
This commit is contained in:
parent
57b3a28008
commit
ae56229afe
|
@ -4,7 +4,7 @@ from datetime import timedelta
|
|||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.mixins import PermissionRequiredMixin
|
||||
from django.db.models import Q, Max
|
||||
from django.db.models import Q, Max, prefetch_related_objects
|
||||
from django.http import Http404
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.utils import timezone
|
||||
|
@ -144,6 +144,7 @@ class RaidDetailView(SingleObjectMixin, MultiModelFormView):
|
|||
.order_by("main__klass")
|
||||
pseudo_no_responses = [RaidResponse(character=user.main, status=None)
|
||||
for user in no_response_users]
|
||||
prefetch_related_objects(pseudo_no_responses, "character__user__rank", "character__user__main")
|
||||
context["responses"] = list(raid.responses.all()) + pseudo_no_responses
|
||||
|
||||
return context
|
||||
|
|
Loading…
Reference in a new issue