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
This commit is contained in:
Henrik Levkowetz 2016-10-26 19:06:06 +00:00
parent 681395ff8e
commit af584c6a1f
4 changed files with 131 additions and 126 deletions

View file

@ -1037,8 +1037,11 @@ class Session(models.Model):
return list(self.materials.filter(type='draft'))
def all_meeting_sessions_for_group(self):
sessions = [s for s in self.meeting.session_set.filter(group=self.group,type=self.type) if s.official_timeslotassignment()]
return sorted(sessions, key = lambda x: x.official_timeslotassignment().timeslot.time)
#sessions = [s for s in self.meeting.session_set.filter(group=self.group,type=self.type) if s.official_timeslotassignment()]
#sessions = sorted(sessions, key = lambda x: x.official_timeslotassignment().timeslot.time)
assignments = self.timeslotassignments.filter(schedule=self.meeting.agenda).order_by('timeslot__time')
sessions = [ a.session for a in assignments ]
return sessions
def all_meeting_recordings(self):
recordings = []

View file

@ -105,23 +105,30 @@ def materials(request, num=None):
'cor_cut_off_date': cor_cut_off_date
})
past_cutoff_date = datetime.date.today() > meeting.get_submission_correction_date()
#sessions = Session.objects.filter(meeting__number=meeting.number, timeslot__isnull=False)
schedule = get_schedule(meeting, None)
sessions = Session.objects.filter(meeting__number=meeting.number, timeslotassignments__schedule=schedule).select_related()
sessions = Session.objects.filter(meeting__number=meeting.number,
timeslotassignments__schedule=schedule).select_related('meeting__agenda','status','group__state','group__parent')
for session in sessions:
session.past_cutoff_date = past_cutoff_date
plenaries = sessions.filter(name__icontains='plenary')
ietf = sessions.filter(group__parent__type__slug = 'area').exclude(group__acronym='edu')
irtf = sessions.filter(group__parent__acronym = 'irtf')
training = sessions.filter(group__acronym__in=['edu','iaoc'], type_id__in=['session', 'other', ])
iab = sessions.filter(group__parent__acronym = 'iab')
cache_version = Document.objects.filter(session__meeting__number=meeting.number).aggregate(Max('time'))["time__max"]
return render(request, "meeting/materials.html", {
'meeting_num': meeting.number,
'plenaries': plenaries, 'ietf': ietf, 'training': training, 'irtf': irtf, 'iab': iab,
'plenaries': plenaries,
'ietf': ietf,
'training': training,
'irtf': irtf,
'iab': iab,
'cut_off_date': cut_off_date,
'cor_cut_off_date': cor_cut_off_date,
'submission_started': now > begin_date,
'cache_version': cache_version,
})
def current_materials(request):

View file

@ -1,6 +1,6 @@
{% load ietf_filters session_filters %}
{% if user|has_role:"Secretariat" or session|can_manage_materials:user and not session.is_material_submission_cutoff %}
{% if user|has_role:"Secretariat" or session|can_manage_materials:user and not session.past_cutoff_date %}
{% with gt=session.group.type_id %}
<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>
<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>
{% endwith %}
{% endif %}

View file

@ -33,133 +33,128 @@
<a class="btn btn-default" href="/meeting/{{meeting_num}}/requests">Meeting requests/conflicts</a>
</p>
{# cache for 15 minutes, as long as there's no proceedings activity. takes 4-8 seconds to generate. #}
{% load cache %}
{% cache 900 ietf_meeting_materials meeting_num cache_version %}
{% with "True" as show_agenda %}
<!-- Plenaries -->
{% if plenaries %}
<h2 class="anchor-target" id="plenaries">Plenaries</h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
{% with "True" as show_agenda %}
<!-- Plenaries -->
{% if plenaries %}
<h2 class="anchor-target" id="plenaries">Plenaries</h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<tbody>
{% for session in plenaries %}
{% include "meeting/group_materials.html" %}
{% endfor %}
</tbody>
</table>
{% endif %}
<tbody>
{% for session in plenaries %}
{% include "meeting/group_materials.html" %}
{% endfor %}
</tbody>
</table>
{% endif %}
<!-- Working groups -->
{% regroup ietf|dictsort:"group.parent.acronym" by group.parent.name as areas %}
{% for sessions in areas %}
<h2 class="anchor-target" id="{{sessions.list.0.group.parent.acronym}}">{{sessions.list.0.group.parent.acronym|upper}} <small>{{ sessions.grouper }}</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<!-- Working groups -->
{% regroup ietf|dictsort:"group.parent.acronym" by group.parent.name as areas %}
{% for sessions in areas %}
<h2 class="anchor-target" id="{{sessions.list.0.group.parent.acronym}}">{{sessions.list.0.group.parent.acronym|upper}} <small>{{ sessions.grouper }}</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<tbody>
{% for session in sessions.list|dictsort:"group.acronym" %}
{% ifchanged session.group.acronym %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endfor %}
<tbody>
{% for session in sessions.list|dictsort:"group.acronym" %}
{% ifchanged session.group.acronym %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endfor %}
<!-- Training Sessions -->
{% if training %}
{% with "False" as show_agenda %}
<h2 class="anchor-target" id="training">Training</h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<!-- Training Sessions -->
{% if training %}
{% with "False" as show_agenda %}
<h2 class="anchor-target" id="training">Training</h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<tbody>
{% for session in training %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endwith %}
{% endif %}
<tbody>
{% for session in training %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endwith %}
{% endif %}
<!-- IAB Sessions -->
{% if iab %}
<h2 class="anchor-target" id="iab">IAB <small>Internet Architecture Board</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<!-- IAB Sessions -->
{% if iab %}
<h2 class="anchor-target" id="iab">IAB <small>Internet Architecture Board</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<tbody>
{% for session in iab %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endif %}
<tbody>
{% for session in iab %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endif %}
<!-- IRTF Sessions -->
{% if irtf %}
<h2 class="anchor-target" id="irtf">IRTF <small>Internet Research Task Force</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<!-- IRTF Sessions -->
{% if irtf %}
<h2 class="anchor-target" id="irtf">IRTF <small>Internet Research Task Force</small></h2>
<table class="table table-condensed table-striped tablesorter">
<thead>
<tr>
<th class="col-md-1">Group</th>
<th class="col-md-1">Agenda</th>
<th class="col-md-1">Minutes</th>
<th class="col-md-6">Slides</th>
<th class="col-md-3">Drafts</th>
</tr>
</thead>
<tbody>
{% for session in irtf|dictsort:"group.acronym" %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endif %}
{% endwith %}
{% endcache %}
<tbody>
{% for session in irtf|dictsort:"group.acronym" %}
{% ifchanged %}
{% include "meeting/group_materials.html" %}
{% endifchanged %}
{% endfor %}
</tbody>
</table>
{% endif %}
{% endwith %}
</div>
<div class="col-md-2 hidden-print bs-docs-sidebar" id="affix">