Commit 23784a43 authored by fred's avatar fred
Browse files

performance: tune the emission view

Down from 179 to 11 queries.
parent ff0ba09a
......@@ -24,7 +24,7 @@ class EmissionDetailView(DetailView):
def get_context_data(self, **kwargs):
context = super(EmissionDetailView, self).get_context_data(**kwargs)
context['sectionName'] = "Emissions"
context['schedules'] = Schedule.objects.filter(emission=self.object).order_by('datetime')
context['schedules'] = Schedule.objects.select_related().filter(emission=self.object).order_by('datetime')
# get all episodes, with an additional attribute to get the date of
# their first diffusion
......@@ -42,7 +42,7 @@ class EmissionDetailView(DetailView):
# get all related soundfiles in a single query
soundfiles = {}
for soundfile in SoundFile.objects.filter(podcastable=True,
for soundfile in SoundFile.objects.select_related().filter(podcastable=True,
fragment=False, episode__emission=self.object):
soundfiles[soundfile.episode_id] = soundfile
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment