rewrite get favorites to return playable data for cards

This commit is contained in:
mungai-njoroge
2023-12-03 23:30:03 +03:00
parent ddfa7f1b03
commit a007b6e1b7
4 changed files with 22 additions and 59 deletions
-40
View File
@@ -1,40 +0,0 @@
from app.models import Album, Artist, Track
def recent_fav_track_serializer(track: Track) -> dict:
"""
Simplifies a track object into a dictionary to remove unused
properties on the client.
"""
return {
"image": track.image,
"title": track.title,
"trackhash": track.trackhash,
"filepath": track.filepath,
}
def recent_fav_album_serializer(album: Album) -> dict:
"""
Simplifies an album object into a dictionary to remove unused
properties on the client.
"""
return {
"image": album.image,
"title": album.og_title,
"albumhash": album.albumhash,
"artist": album.albumartists[0].name,
"colors": album.colors,
}
def recent_fav_artist_serializer(artist: Artist) -> dict:
"""
Simplifies an artist object into a dictionary to remove unused
properties on the client.
"""
return {
"image": artist.image,
"name": artist.name,
"artisthash": artist.artisthash,
}
+1
View File
@@ -15,6 +15,7 @@ def serialize_track(track: Track, to_remove: set = {}, remove_disc=True) -> dict
"disc",
"track",
"artist_hashes",
"created_date",
}.union(to_remove)
if not remove_disc: