Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
fd68689e
Commit
fd68689e
authored
Sep 14, 2013
by
fred
Browse files
rework main_sound prefetching
parent
c61a52a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
fd68689e
...
...
@@ -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]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment