Skip to content

Commit af584c6

Browse files
committed
Removed caching of the materials page (edit buttons are different for different users), and used select_related() and code re-write to reduce the sql query count from ~1900 to ~600, query time from ~2s to ~0.5s. More can be done, but the page response time is more acceptable now.
- Legacy-Id: 12218
1 parent 681395f commit af584c6

4 files changed

Lines changed: 140 additions & 135 deletions

File tree

ietf/meeting/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,11 @@ def drafts(self):
10371037
return list(self.materials.filter(type='draft'))
10381038

10391039
def all_meeting_sessions_for_group(self):
1040-
sessions = [s for s in self.meeting.session_set.filter(group=self.group,type=self.type) if s.official_timeslotassignment()]
1041-
return sorted(sessions, key = lambda x: x.official_timeslotassignment().timeslot.time)
1040+
#sessions = [s for s in self.meeting.session_set.filter(group=self.group,type=self.type) if s.official_timeslotassignment()]
1041+
#sessions = sorted(sessions, key = lambda x: x.official_timeslotassignment().timeslot.time)
1042+
assignments = self.timeslotassignments.filter(schedule=self.meeting.agenda).order_by('timeslot__time')
1043+
sessions = [ a.session for a in assignments ]
1044+
return sessions
10421045

10431046
def all_meeting_recordings(self):
10441047
recordings = []

ietf/meeting/views.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,30 @@ def materials(request, num=None):
105105
'cor_cut_off_date': cor_cut_off_date
106106
})
107107

108+
past_cutoff_date = datetime.date.today() > meeting.get_submission_correction_date()
109+
108110
#sessions = Session.objects.filter(meeting__number=meeting.number, timeslot__isnull=False)
109111
schedule = get_schedule(meeting, None)
110-
sessions = Session.objects.filter(meeting__number=meeting.number, timeslotassignments__schedule=schedule).select_related()
112+
sessions = Session.objects.filter(meeting__number=meeting.number,
113+
timeslotassignments__schedule=schedule).select_related('meeting__agenda','status','group__state','group__parent')
114+
for session in sessions:
115+
session.past_cutoff_date = past_cutoff_date
111116
plenaries = sessions.filter(name__icontains='plenary')
112117
ietf = sessions.filter(group__parent__type__slug = 'area').exclude(group__acronym='edu')
113118
irtf = sessions.filter(group__parent__acronym = 'irtf')
114119
training = sessions.filter(group__acronym__in=['edu','iaoc'], type_id__in=['session', 'other', ])
115120
iab = sessions.filter(group__parent__acronym = 'iab')
116121

117-
cache_version = Document.objects.filter(session__meeting__number=meeting.number).aggregate(Max('time'))["time__max"]
118122
return render(request, "meeting/materials.html", {
119123
'meeting_num': meeting.number,
120-
'plenaries': plenaries, 'ietf': ietf, 'training': training, 'irtf': irtf, 'iab': iab,
124+
'plenaries': plenaries,
125+
'ietf': ietf,
126+
'training': training,
127+
'irtf': irtf,
128+
'iab': iab,
121129
'cut_off_date': cut_off_date,
122130
'cor_cut_off_date': cor_cut_off_date,
123131
'submission_started': now > begin_date,
124-
'cache_version': cache_version,
125132
})
126133

127134
def current_materials(request):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load ietf_filters session_filters %}
2-
{% if user|has_role:"Secretariat" or session|can_manage_materials:user and not session.is_material_submission_cutoff %}
2+
{% if user|has_role:"Secretariat" or session|can_manage_materials:user and not session.past_cutoff_date %}
33
{% with gt=session.group.type_id %}
4-
<a class="button btn-default btn-sm" href="{% url 'ietf.meeting.views.session_details' num=session.meeting.number acronym=session.group.acronym %}{% if gt == 'wg' or gt == 'rg' or gt == 'ag' %}{% else %}#session_{{session.pk}}{% endif %}">Edit</a>
4+
<a class="button btn-default btn-sm" href="{% url 'ietf.meeting.views.session_details' num=session.meeting.number acronym=session.group.acronym %}{% if gt == 'wg' or gt == 'rg' or gt == 'ag' %}{% else %}#session_{{session.pk}}{% endif %}">Edit</a>
55
{% endwith %}
66
{% endif %}

ietf/templates/meeting/materials.html

Lines changed: 122 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -33,133 +33,128 @@ <h1>IETF {{ meeting_num }} meeting materials</h1>
3333
<a class="btn btn-default" href="/meeting/{{meeting_num}}/requests">Meeting requests/conflicts</a>
3434
</p>
3535

36-
{# cache for 15 minutes, as long as there's no proceedings activity. takes 4-8 seconds to generate. #}
37-
{% load cache %}
38-
{% cache 900 ietf_meeting_materials meeting_num cache_version %}
39-
40-
{% with "True" as show_agenda %}
41-
<!-- Plenaries -->
42-
{% if plenaries %}
43-
<h2 class="anchor-target" id="plenaries">Plenaries</h2>
44-
<table class="table table-condensed table-striped tablesorter">
45-
<thead>
46-
<tr>
47-
<th class="col-md-1">Group</th>
48-
<th class="col-md-1">Agenda</th>
49-
<th class="col-md-1">Minutes</th>
50-
<th class="col-md-6">Slides</th>
51-
<th class="col-md-3">Drafts</th>
52-
</tr>
53-
</thead>
54-
55-
<tbody>
56-
{% for session in plenaries %}
57-
{% include "meeting/group_materials.html" %}
58-
{% endfor %}
59-
</tbody>
60-
</table>
61-
{% endif %}
62-
63-
<!-- Working groups -->
64-
{% regroup ietf|dictsort:"group.parent.acronym" by group.parent.name as areas %}
65-
{% for sessions in areas %}
66-
<h2 class="anchor-target" id="{{sessions.list.0.group.parent.acronym}}">{{sessions.list.0.group.parent.acronym|upper}} <small>{{ sessions.grouper }}</small></h2>
67-
<table class="table table-condensed table-striped tablesorter">
68-
<thead>
69-
<tr>
70-
<th class="col-md-1">Group</th>
71-
<th class="col-md-1">Agenda</th>
72-
<th class="col-md-1">Minutes</th>
73-
<th class="col-md-6">Slides</th>
74-
<th class="col-md-3">Drafts</th>
75-
</tr>
76-
</thead>
77-
78-
<tbody>
79-
{% for session in sessions.list|dictsort:"group.acronym" %}
80-
{% ifchanged session.group.acronym %}
81-
{% include "meeting/group_materials.html" %}
82-
{% endifchanged %}
83-
{% endfor %}
84-
</tbody>
85-
</table>
86-
{% endfor %}
87-
88-
<!-- Training Sessions -->
89-
{% if training %}
90-
{% with "False" as show_agenda %}
91-
<h2 class="anchor-target" id="training">Training</h2>
92-
<table class="table table-condensed table-striped tablesorter">
93-
<thead>
94-
<tr>
95-
<th class="col-md-1">Group</th>
96-
<th class="col-md-1">Agenda</th>
97-
<th class="col-md-1">Minutes</th>
98-
<th class="col-md-6">Slides</th>
99-
<th class="col-md-3">Drafts</th>
100-
</tr>
101-
</thead>
102-
103-
<tbody>
104-
{% for session in training %}
105-
{% ifchanged %}
106-
{% include "meeting/group_materials.html" %}
107-
{% endifchanged %}
108-
{% endfor %}
109-
</tbody>
110-
</table>
111-
{% endwith %}
112-
{% endif %}
113-
114-
<!-- IAB Sessions -->
115-
{% if iab %}
116-
<h2 class="anchor-target" id="iab">IAB <small>Internet Architecture Board</small></h2>
117-
<table class="table table-condensed table-striped tablesorter">
118-
<thead>
119-
<tr>
120-
<th class="col-md-1">Group</th>
121-
<th class="col-md-1">Agenda</th>
122-
<th class="col-md-1">Minutes</th>
123-
<th class="col-md-6">Slides</th>
124-
<th class="col-md-3">Drafts</th>
125-
</tr>
126-
</thead>
127-
128-
<tbody>
129-
{% for session in iab %}
130-
{% ifchanged %}
131-
{% include "meeting/group_materials.html" %}
132-
{% endifchanged %}
133-
{% endfor %}
134-
</tbody>
135-
</table>
136-
{% endif %}
137-
138-
<!-- IRTF Sessions -->
139-
{% if irtf %}
140-
<h2 class="anchor-target" id="irtf">IRTF <small>Internet Research Task Force</small></h2>
141-
<table class="table table-condensed table-striped tablesorter">
142-
<thead>
143-
<tr>
144-
<th class="col-md-1">Group</th>
145-
<th class="col-md-1">Agenda</th>
146-
<th class="col-md-1">Minutes</th>
147-
<th class="col-md-6">Slides</th>
148-
<th class="col-md-3">Drafts</th>
149-
</tr>
150-
</thead>
151-
152-
<tbody>
153-
{% for session in irtf|dictsort:"group.acronym" %}
154-
{% ifchanged %}
155-
{% include "meeting/group_materials.html" %}
156-
{% endifchanged %}
157-
{% endfor %}
158-
</tbody>
159-
</table>
160-
{% endif %}
161-
{% endwith %}
162-
{% endcache %}
36+
{% with "True" as show_agenda %}
37+
<!-- Plenaries -->
38+
{% if plenaries %}
39+
<h2 class="anchor-target" id="plenaries">Plenaries</h2>
40+
<table class="table table-condensed table-striped tablesorter">
41+
<thead>
42+
<tr>
43+
<th class="col-md-1">Group</th>
44+
<th class="col-md-1">Agenda</th>
45+
<th class="col-md-1">Minutes</th>
46+
<th class="col-md-6">Slides</th>
47+
<th class="col-md-3">Drafts</th>
48+
</tr>
49+
</thead>
50+
51+
<tbody>
52+
{% for session in plenaries %}
53+
{% include "meeting/group_materials.html" %}
54+
{% endfor %}
55+
</tbody>
56+
</table>
57+
{% endif %}
58+
59+
<!-- Working groups -->
60+
{% regroup ietf|dictsort:"group.parent.acronym" by group.parent.name as areas %}
61+
{% for sessions in areas %}
62+
<h2 class="anchor-target" id="{{sessions.list.0.group.parent.acronym}}">{{sessions.list.0.group.parent.acronym|upper}} <small>{{ sessions.grouper }}</small></h2>
63+
<table class="table table-condensed table-striped tablesorter">
64+
<thead>
65+
<tr>
66+
<th class="col-md-1">Group</th>
67+
<th class="col-md-1">Agenda</th>
68+
<th class="col-md-1">Minutes</th>
69+
<th class="col-md-6">Slides</th>
70+
<th class="col-md-3">Drafts</th>
71+
</tr>
72+
</thead>
73+
74+
<tbody>
75+
{% for session in sessions.list|dictsort:"group.acronym" %}
76+
{% ifchanged session.group.acronym %}
77+
{% include "meeting/group_materials.html" %}
78+
{% endifchanged %}
79+
{% endfor %}
80+
</tbody>
81+
</table>
82+
{% endfor %}
83+
84+
<!-- Training Sessions -->
85+
{% if training %}
86+
{% with "False" as show_agenda %}
87+
<h2 class="anchor-target" id="training">Training</h2>
88+
<table class="table table-condensed table-striped tablesorter">
89+
<thead>
90+
<tr>
91+
<th class="col-md-1">Group</th>
92+
<th class="col-md-1">Agenda</th>
93+
<th class="col-md-1">Minutes</th>
94+
<th class="col-md-6">Slides</th>
95+
<th class="col-md-3">Drafts</th>
96+
</tr>
97+
</thead>
98+
99+
<tbody>
100+
{% for session in training %}
101+
{% ifchanged %}
102+
{% include "meeting/group_materials.html" %}
103+
{% endifchanged %}
104+
{% endfor %}
105+
</tbody>
106+
</table>
107+
{% endwith %}
108+
{% endif %}
109+
110+
<!-- IAB Sessions -->
111+
{% if iab %}
112+
<h2 class="anchor-target" id="iab">IAB <small>Internet Architecture Board</small></h2>
113+
<table class="table table-condensed table-striped tablesorter">
114+
<thead>
115+
<tr>
116+
<th class="col-md-1">Group</th>
117+
<th class="col-md-1">Agenda</th>
118+
<th class="col-md-1">Minutes</th>
119+
<th class="col-md-6">Slides</th>
120+
<th class="col-md-3">Drafts</th>
121+
</tr>
122+
</thead>
123+
124+
<tbody>
125+
{% for session in iab %}
126+
{% ifchanged %}
127+
{% include "meeting/group_materials.html" %}
128+
{% endifchanged %}
129+
{% endfor %}
130+
</tbody>
131+
</table>
132+
{% endif %}
133+
134+
<!-- IRTF Sessions -->
135+
{% if irtf %}
136+
<h2 class="anchor-target" id="irtf">IRTF <small>Internet Research Task Force</small></h2>
137+
<table class="table table-condensed table-striped tablesorter">
138+
<thead>
139+
<tr>
140+
<th class="col-md-1">Group</th>
141+
<th class="col-md-1">Agenda</th>
142+
<th class="col-md-1">Minutes</th>
143+
<th class="col-md-6">Slides</th>
144+
<th class="col-md-3">Drafts</th>
145+
</tr>
146+
</thead>
147+
148+
<tbody>
149+
{% for session in irtf|dictsort:"group.acronym" %}
150+
{% ifchanged %}
151+
{% include "meeting/group_materials.html" %}
152+
{% endifchanged %}
153+
{% endfor %}
154+
</tbody>
155+
</table>
156+
{% endif %}
157+
{% endwith %}
163158
</div>
164159

165160
<div class="col-md-2 hidden-print bs-docs-sidebar" id="affix">

0 commit comments

Comments
 (0)