Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Auri
funkwhale
Commits
a495ace3
Commit
a495ace3
authored
Jan 04, 2019
by
Auri
Browse files
Credits: prefetch credits in various sets
parent
a63c5ddf
Pipeline
#2828
failed with stages
in 33 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/music/views.py
View file @
a495ace3
...
...
@@ -97,6 +97,7 @@ class AlbumViewSet(viewsets.ReadOnlyModelViewSet):
models
.
Track
.
objects
.
select_related
(
"artist"
)
.
with_playable_uploads
(
utils
.
get_actor_from_request
(
self
.
request
))
.
order_for_album
()
.
prefetch_related
(
"track_credits"
)
)
qs
=
queryset
.
prefetch_related
(
Prefetch
(
"tracks"
,
queryset
=
tracks
))
return
qs
.
distinct
()
...
...
@@ -190,7 +191,7 @@ class TrackViewSet(TagViewSetMixin, viewsets.ReadOnlyModelViewSet):
queryset
=
queryset
.
with_playable_uploads
(
utils
.
get_actor_from_request
(
self
.
request
)
)
)
.
prefetch_related
(
"track_credits"
)
return
queryset
@
detail_route
(
methods
=
[
"get"
])
...
...
@@ -367,6 +368,7 @@ class UploadViewSet(
models
.
Upload
.
objects
.
all
()
.
order_by
(
"-creation_date"
)
.
select_related
(
"library"
,
"track__artist"
,
"track__album__artist"
)
.
prefetch_related
(
"track__track_credits"
)
)
serializer_class
=
serializers
.
UploadForOwnerSerializer
permission_classes
=
[
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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