From c8f678b6003a30fec86c5240a97ce549016dd29e Mon Sep 17 00:00:00 2001 From: krateng Date: Sun, 3 Apr 2022 16:26:06 +0200 Subject: [PATCH] Fixed removal of empty artists --- maloja/database/sqldb.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index 42cc50a..8400292 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -632,13 +632,11 @@ def clean_db(): if a2+a1>0: log(f"Deleted {a2} tracks without scrobbles ({a1} track artist entries)") ### Delete artists that have no tracks - # we actually don't wanna do that as it will break collection artists - # that don't have songs themselves - #a3 = conn.execute(sql.text(''' - # delete from artists where id not in (select artist_id from trackartists) - #''')).rowcount - # - #if a3>0: log(f"Deleted {a3} artists without tracks") + a3 = conn.execute(sql.text(''' + delete from artists where id not in (select artist_id from trackartists) and id not in (select target_artist from associated_artists) + ''')).rowcount + + if a3>0: log(f"Deleted {a3} artists without tracks") ### Delete tracks that have no artists (delete their scrobbles first) a4 = conn.execute(sql.text('''