|
1 | | -# Copyright The IETF Trust 2013-2019, All Rights Reserved |
| 1 | +# Copyright The IETF Trust 2013-2020, All Rights Reserved |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 |
|
4 | 4 |
|
|
11 | 11 | from tempfile import mkstemp |
12 | 12 |
|
13 | 13 | from django.http import HttpRequest, Http404 |
14 | | -from django.db.models import Max, Q |
| 14 | +from django.db.models import Max, Q, Prefetch |
15 | 15 | from django.conf import settings |
16 | 16 | from django.core.cache import cache |
17 | 17 | from django.urls import reverse |
|
27 | 27 | from ietf.liaisons.utils import get_person_for_user |
28 | 28 | from ietf.mailtrigger.utils import gather_address_lists |
29 | 29 | from ietf.person.models import Person |
30 | | -from ietf.meeting.models import Meeting, Schedule, TimeSlot, SchedTimeSessAssignment, ImportantDate, SchedulingEvent |
| 30 | +from ietf.meeting.models import Meeting, Schedule, TimeSlot, SchedTimeSessAssignment, ImportantDate, SchedulingEvent, Session |
31 | 31 | from ietf.meeting.utils import session_requested_by, add_event_info_to_session_qs |
32 | 32 | from ietf.name.models import ImportantDateName |
33 | 33 | from ietf.utils.history import find_history_active_at, find_history_replacements_active_at |
@@ -164,23 +164,19 @@ def get_schedule_by_name(meeting, owner, name): |
164 | 164 | else: |
165 | 165 | return meeting.schedule_set.filter(name = name).first() |
166 | 166 |
|
167 | | -def preprocess_assignments_for_agenda(assignments_queryset, meeting): |
168 | | - # prefetch was not improving performance, except for json_agenda, so |
169 | | - # it was removed. Saved in comment in case others find it useful |
170 | | - # in the future ... |
171 | | - # |
172 | | - #.prefetch_related( |
173 | | - # Prefetch("session__materials", |
174 | | - # queryset=Document.objects.exclude(states__type=F("type"),states__slug='deleted').select_related("group").order_by("sessionpresentation__order"), |
175 | | - # to_attr="prefetched_active_materials", |
176 | | - # ), |
177 | | - # "timeslot__meeting", |
178 | | - # ) |
| 167 | +def preprocess_assignments_for_agenda(assignments_queryset, meeting, extra_prefetches=()): |
179 | 168 | assignments_queryset = assignments_queryset.select_related( |
180 | 169 | "timeslot", "timeslot__location", "timeslot__type", |
181 | | - "session", "session__group", "session__group__charter", |
182 | | - "session__group__charter__group", |
183 | | - ) |
| 170 | + ).prefetch_related( |
| 171 | + Prefetch( |
| 172 | + "session", |
| 173 | + queryset=add_event_info_to_session_qs(Session.objects.all().prefetch_related( |
| 174 | + 'group', 'group__charter', 'group__charter__group', |
| 175 | + )) |
| 176 | + ), |
| 177 | + *extra_prefetches |
| 178 | + ) |
| 179 | + |
184 | 180 |
|
185 | 181 | # removed list(); it was consuming a very large amount of processor time |
186 | 182 | # assignments = list(assignments_queryset) # make sure we're set in stone |
@@ -217,11 +213,6 @@ def preprocess_assignments_for_agenda(assignments_queryset, meeting): |
217 | 213 | if a.session and a.session.historic_group and a.session.historic_group.parent_id: |
218 | 214 | a.session.historic_group.historic_parent = parent_replacements.get(a.session.historic_group.parent_id) |
219 | 215 |
|
220 | | - # add current session status |
221 | | - sessions = {a.session_id: a.session for a in assignments if a.session} |
222 | | - for e in SchedulingEvent.objects.filter(session__in=sessions.keys()).order_by('time', 'id').iterator(): |
223 | | - sessions[e.session_id].current_status = e.status_id |
224 | | - |
225 | 216 | return assignments |
226 | 217 |
|
227 | 218 | def read_session_file(type, num, doc): |
|
0 commit comments