Commit d1ad391c authored by Ciaran Ainsworth's avatar Ciaran Ainsworth Committed by Georg Krause
Browse files

Add prefetched covers to history view

parent 79a8fa59
...@@ -56,7 +56,7 @@ class ListeningViewSet( ...@@ -56,7 +56,7 @@ class ListeningViewSet(
) )
tracks = Track.objects.with_playable_uploads( tracks = Track.objects.with_playable_uploads(
music_utils.get_actor_from_request(self.request) 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)) return queryset.prefetch_related(Prefetch("track", queryset=tracks))
def get_serializer_context(self): def get_serializer_context(self):
......
...@@ -162,17 +162,19 @@ def serialize_artist_simple(artist): ...@@ -162,17 +162,19 @@ def serialize_artist_simple(artist):
"content_category": artist.content_category, "content_category": artist.content_category,
} }
data["description"] = ( if "description" in artist._state.fields_cache:
common_serializers.ContentSerializer(artist.description).data data["description"] = (
if artist.description common_serializers.ContentSerializer(artist.description).data
else None if artist.description
) else None
)
data["cover"] = ( if "attachment_cover" in artist._state.fields_cache:
cover_field.to_representation(artist.attachment_cover) data["cover"] = (
if artist.attachment_cover cover_field.to_representation(artist.attachment_cover)
else None if artist.attachment_cover
) else None
)
if artist.get_channel(): if artist.get_channel():
data["channel"] = str(artist.channel.uuid) data["channel"] = str(artist.channel.uuid)
......
Supports Markdown
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