Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
funkwhale
funkwhale
Commits
d1ad391c
Commit
d1ad391c
authored
May 09, 2021
by
Ciaran Ainsworth
Committed by
Georg Krause
May 19, 2021
Browse files
Add prefetched covers to history view
parent
79a8fa59
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/funkwhale_api/history/views.py
View file @
d1ad391c
...
...
@@ -56,7 +56,7 @@ class ListeningViewSet(
)
tracks
=
Track
.
objects
.
with_playable_uploads
(
music_utils
.
get_actor_from_request
(
self
.
request
)
).
select_related
(
"artist"
,
"album__artist"
,
"attributed_to"
)
).
select_related
(
"artist"
,
"album__artist"
,
"attributed_to"
,
"artist__attachment_cover"
)
return
queryset
.
prefetch_related
(
Prefetch
(
"track"
,
queryset
=
tracks
))
def
get_serializer_context
(
self
):
...
...
api/funkwhale_api/music/serializers.py
View file @
d1ad391c
...
...
@@ -162,17 +162,19 @@ def serialize_artist_simple(artist):
"content_category"
:
artist
.
content_category
,
}
data
[
"description"
]
=
(
common_serializers
.
ContentSerializer
(
artist
.
description
).
data
if
artist
.
description
else
None
)
if
"description"
in
artist
.
_state
.
fields_cache
:
data
[
"description"
]
=
(
common_serializers
.
ContentSerializer
(
artist
.
description
).
data
if
artist
.
description
else
None
)
data
[
"cover"
]
=
(
cover_field
.
to_representation
(
artist
.
attachment_cover
)
if
artist
.
attachment_cover
else
None
)
if
"attachment_cover"
in
artist
.
_state
.
fields_cache
:
data
[
"cover"
]
=
(
cover_field
.
to_representation
(
artist
.
attachment_cover
)
if
artist
.
attachment_cover
else
None
)
if
artist
.
get_channel
():
data
[
"channel"
]
=
str
(
artist
.
channel
.
uuid
)
...
...
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