Prefetch a couple of things in the agenda view to reduce the number of
queries for IETF 106 from about 3800 to about 235. - Legacy-Id: 18103
This commit is contained in:
parent
15de8ef380
commit
a373f1d55c
|
@ -9,7 +9,7 @@ import re
|
|||
from tempfile import mkstemp
|
||||
|
||||
from django.http import HttpRequest, Http404
|
||||
from django.db.models import Max, Q, Prefetch
|
||||
from django.db.models import F, Max, Q, Prefetch
|
||||
from django.conf import settings
|
||||
from django.core.cache import cache
|
||||
from django.urls import reverse
|
||||
|
@ -164,13 +164,17 @@ def get_schedule_by_name(meeting, owner, name):
|
|||
return meeting.schedule_set.filter(name = name).first()
|
||||
|
||||
def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefetches=()):
|
||||
assignments_queryset = assignments_queryset.select_related(
|
||||
"timeslot", "timeslot__location", "timeslot__type",
|
||||
).prefetch_related(
|
||||
assignments_queryset = assignments_queryset.prefetch_related(
|
||||
'timeslot', 'timeslot__type', 'timeslot__meeting',
|
||||
'timeslot__location', 'timeslot__location__floorplan', 'timeslot__location__urlresource_set',
|
||||
Prefetch(
|
||||
"session",
|
||||
queryset=add_event_info_to_session_qs(Session.objects.all().prefetch_related(
|
||||
'group', 'group__charter', 'group__charter__group',
|
||||
Prefetch('materials',
|
||||
queryset=Document.objects.exclude(states__type=F("type"), states__slug='deleted').order_by('sessionpresentation__order').prefetch_related('states'),
|
||||
to_attr='prefetched_active_materials'
|
||||
)
|
||||
))
|
||||
),
|
||||
*extra_prefetches
|
||||
|
@ -212,6 +216,12 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefe
|
|||
if a.session and a.session.historic_group and a.session.historic_group.parent_id:
|
||||
a.session.historic_group.historic_parent = parent_replacements.get(a.session.historic_group.parent_id)
|
||||
|
||||
for d in a.session.prefetched_active_materials:
|
||||
# make sure these are precomputed with the meeting instead
|
||||
# of having to look it up
|
||||
d.get_href(meeting=meeting)
|
||||
d.get_versionless_href(meeting=meeting)
|
||||
|
||||
return assignments
|
||||
|
||||
def read_session_file(type, num, doc):
|
||||
|
|
|
@ -391,14 +391,14 @@ class Room(models.Model):
|
|||
return self.functional_name
|
||||
# audio stream support
|
||||
def audio_stream_url(self):
|
||||
urlresource = self.urlresource_set.filter(name_id='audiostream').first()
|
||||
return urlresource.url if urlresource else None
|
||||
urlresources = [ur for ur in self.urlresource_set.all() if ur.name_id == 'audiostream']
|
||||
return urlresources[0].url if urlresources else None
|
||||
def video_stream_url(self):
|
||||
urlresource = self.urlresource_set.filter(name_id__in=['meetecho', ]).first()
|
||||
return urlresource.url if urlresource else None
|
||||
urlresources = [ur for ur in self.urlresource_set.all() if ur.name_id in ['meetecho']]
|
||||
return urlresources[0].url if urlresources else None
|
||||
def webex_url(self):
|
||||
urlresource = self.urlresource_set.filter(name_id__in=['webex', ]).first()
|
||||
return urlresource.url if urlresource else None
|
||||
urlresources = [ur for ur in self.urlresource_set.all() if ur.name_id in ['webex']]
|
||||
return urlresources[0].url if urlresources else None
|
||||
#
|
||||
class Meta:
|
||||
ordering = ["-id"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div id="session{{ session.pk }}" class="session {% if not session.group.parent.scheduling_color %}untoggleable{% endif %} {% if session.parent_acronym %}parent-{{ session.parent_acronym }}{% endif %}" style="width:{{ session.layout_width }}em;" data-duration="{{ session.requested_duration.total_seconds }}" {% if session.attendees != None %}data-attendees="{{ session.attendees }}"{% endif %}>
|
||||
<div id="session{{ session.pk }}" class="session {% if not session.group.parent.scheduling_color %}untoggleable{% endif %} {% if session.parent_acronym %}parent-{{ session.parent_acronym }}{% endif %} {% if session.is_tombstone %}tombstone{% endif %}" style="width:{{ session.layout_width }}em;" data-duration="{{ session.requested_duration.total_seconds }}" {% if session.attendees != None %}data-attendees="{{ session.attendees }}"{% endif %}>
|
||||
<div class="session-label {% if session.group and session.group.is_bof %}bof-session{% endif %}">
|
||||
{{ session.scheduling_label }}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue