Files
swingmusic-extended/app/serializers/artist.py
T
cwilvx b9ad07441a store playcount and duration on the track table
+ allow sorting all items with those two
+ add methods to update scrobble info
2024-06-30 19:33:13 +03:00

28 lines
530 B
Python

from dataclasses import asdict
from app.models.artist import Artist
def serialize_for_card(artist: Artist):
try:
artist_dict = asdict(artist)
except TypeError:
return {}
props_to_remove = {
"is_favorite",
"trackcount",
"duration",
"albumcount",
"playcount",
}
for key in props_to_remove:
artist_dict.pop(key, None)
return artist_dict
def serialize_for_cards(artists: list[Artist]):
return [serialize_for_card(a) for a in artists]