db: Use the new match / case statement in user.py:do_factory()
This is cleaner than using a bunch of elif-s to pick the right playlist type Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
289420e504
commit
0c7a4a4a4c
24
db/user.py
24
db/user.py
|
@ -140,17 +140,19 @@ class UserTable(playlist.Model):
|
||||||
sql.execute("DROP TABLE temp_playlist_map")
|
sql.execute("DROP TABLE temp_playlist_map")
|
||||||
|
|
||||||
def do_factory(self, row):
|
def do_factory(self, row):
|
||||||
if row["name"] == "Collection":
|
match row["name"]:
|
||||||
return Collection(row)
|
case "Collection":
|
||||||
elif row["name"] == "Favorites":
|
return Collection(row)
|
||||||
return UserPlaylist(row, "emmental-favorites", "playlist_map")
|
case "Favorites":
|
||||||
elif row["name"] == "New Tracks":
|
return UserPlaylist(row, "emmental-favorites", "playlist_map")
|
||||||
return UserPlaylist(row, "starred", "temp_playlist_map")
|
case "New Tracks":
|
||||||
elif row["name"] == "Previous":
|
return UserPlaylist(row, "starred", "temp_playlist_map")
|
||||||
return Previous(row)
|
case "Previous":
|
||||||
elif row["name"] == "Queued Tracks":
|
return Previous(row)
|
||||||
return QueuedTracks(row)
|
case "Queued Tracks":
|
||||||
return UserPlaylist(row, "audio-x-generic", "playlist_map")
|
return QueuedTracks(row)
|
||||||
|
case _:
|
||||||
|
return UserPlaylist(row, "audio-x-generic", "playlist_map")
|
||||||
|
|
||||||
def do_insert(self, plstate, name):
|
def do_insert(self, plstate, name):
|
||||||
return sql.execute("INSERT INTO playlists (plstateid, name, sort) "
|
return sql.execute("INSERT INTO playlists (plstateid, name, sort) "
|
||||||
|
|
Loading…
Reference in New Issue