Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
panikweb
Commits
23784a43
Commit
23784a43
authored
Aug 31, 2013
by
fred
Browse files
performance: tune the emission view
Down from 179 to 11 queries.
parent
ff0ba09a
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikweb/views.py
View file @
23784a43
...
...
@@ -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
...
...
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