mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
fix: duplication of artist albums on album/from-artist
+ remove more fields from artist, album and artist models on serializers
This commit is contained in:
@@ -23,11 +23,20 @@ def serialize_for_card(album: Album):
|
||||
props_to_remove = {
|
||||
"duration",
|
||||
"count",
|
||||
"artisthashes",
|
||||
"albumartists_hashes",
|
||||
"created_date",
|
||||
"og_title",
|
||||
"base_title",
|
||||
"genres",
|
||||
"playcount"
|
||||
"playcount",
|
||||
"trackcount",
|
||||
"type",
|
||||
"playduration",
|
||||
"genrehashes",
|
||||
"extra",
|
||||
"id",
|
||||
"lastplayed",
|
||||
}
|
||||
|
||||
return album_serializer(album, props_to_remove)
|
||||
|
||||
@@ -15,6 +15,15 @@ def serialize_for_card(artist: Artist):
|
||||
"duration",
|
||||
"albumcount",
|
||||
"playcount",
|
||||
"playduration",
|
||||
"playcount",
|
||||
"lastplayed",
|
||||
"id",
|
||||
"genres",
|
||||
"genrehashes",
|
||||
"extra",
|
||||
"created_date",
|
||||
"date",
|
||||
}
|
||||
|
||||
for key in props_to_remove:
|
||||
|
||||
@@ -3,7 +3,7 @@ from dataclasses import asdict
|
||||
from app.models.track import Track
|
||||
|
||||
|
||||
def serialize_track(track: Track, to_remove: set = {}, remove_disc=True) -> dict:
|
||||
def serialize_track(track: Track, to_remove: set = set(), remove_disc=True) -> dict:
|
||||
album_dict = asdict(track)
|
||||
# is_favorite @property is not included in asdict
|
||||
album_dict["is_favorite"] = track.is_favorite
|
||||
@@ -21,6 +21,11 @@ def serialize_track(track: Track, to_remove: set = {}, remove_disc=True) -> dict
|
||||
"created_date",
|
||||
"fav_userids",
|
||||
"playcount",
|
||||
"genrehashes",
|
||||
"id",
|
||||
"lastplayed",
|
||||
"playduration",
|
||||
"genres",
|
||||
}.union(to_remove)
|
||||
|
||||
if not remove_disc:
|
||||
@@ -42,6 +47,6 @@ def serialize_track(track: Track, to_remove: set = {}, remove_disc=True) -> dict
|
||||
|
||||
|
||||
def serialize_tracks(
|
||||
tracks: list[Track], _remove: set = {}, remove_disc=True
|
||||
tracks: list[Track], _remove: set = set(), remove_disc=True
|
||||
) -> list[dict]:
|
||||
return [serialize_track(t, _remove, remove_disc) for t in tracks]
|
||||
|
||||
Reference in New Issue
Block a user