From e18dffbd2fcfa021124df1521e367003fdd55604 Mon Sep 17 00:00:00 2001 From: krateng Date: Wed, 29 Mar 2023 17:06:07 +0200 Subject: [PATCH] Adjusted DB cleanup to account for albums --- maloja/database/sqldb.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index 26f2f62..f8d89aa 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -1236,11 +1236,16 @@ def clean_db(dbconn=None): # tracks with no scrobbles (trackartist entries first) "from trackartists where track_id in (select id from tracks where id not in (select track_id from scrobbles))", "from tracks where id not in (select track_id from scrobbles)", - # artists with no tracks - "from artists where id not in (select artist_id from trackartists) and id not in (select target_artist from associated_artists)", + # artists with no tracks AND no albums + "from artists where id not in (select artist_id from trackartists) \ + and id not in (select target_artist from associated_artists) \ + and id not in (select artist_id from albumartists)", # tracks with no artists (scrobbles first) "from scrobbles where track_id in (select id from tracks where id not in (select track_id from trackartists))", - "from tracks where id not in (select track_id from trackartists)" + "from tracks where id not in (select track_id from trackartists)", + # albums with no tracks (albumartist entries first) + "from albumartists where album_id in (select id from albums where id not in (select album_id from tracks))", + "from albums where id not in (select album_id from tracks)" ] for d in to_delete: