Fixed really slow SQL

This commit is contained in:
Agate 2020-07-09 11:51:58 +02:00
parent 8b0ce6ad33
commit 1295144681
6 changed files with 19 additions and 12 deletions

View file

@ -101,7 +101,7 @@ class ArtistAlbumSerializer(serializers.Serializer):
return o.artist_id
def get_tracks_count(self, o):
return o._tracks_count
return len(o.tracks.all())
def get_is_playable(self, obj):
try:
@ -210,7 +210,7 @@ class AlbumSerializer(OptionalDescriptionMixin, serializers.Serializer):
return serialize_artist_simple(o.artist)
def get_tracks_count(self, o):
return getattr(o, "_tracks_count", None)
return len(o.tracks.all())
def get_is_playable(self, obj):
try: