Commit fd68689e authored by fred's avatar fred

rework main_sound prefetching

parent c61a52a0
......@@ -49,14 +49,18 @@ class EmissionMixin:
# get all related soundfiles in a single query
soundfiles = {}
if episode_ids is not None:
for episode_id in episode_ids:
soundfiles[episode_id] = None
else:
for episode in Episode.objects.filter(emission=emission):
soundfiles[episode.id] = None
for soundfile in SoundFile.objects.select_related().filter(podcastable=True,
fragment=False, episode__emission=emission):
soundfiles[soundfile.episode_id] = soundfile
# replace dynamic property by a static attribute, to avoid database
# lookups
for episode in context['episodes']:
episode.main_sound = soundfiles.get(episode.id)
Episode.set_prefetched_soundfiles(soundfiles)
#context['futurEpisodes'] = context['episodes'].filter(first_diffusion='2013')[0:3]
......
Markdown is supported
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