diff --git a/maloja/database/dbcache.py b/maloja/database/dbcache.py index d505e59..a94c622 100644 --- a/maloja/database/dbcache.py +++ b/maloja/database/dbcache.py @@ -46,9 +46,14 @@ def cached_wrapper(inner_func): def invalidate_caches(scrobbletime): + cleared, kept = 0, 0 for k in cache.keys(): if (k[3] is None or scrobbletime >= k[3]) and (k[4] is None or scrobbletime <= k[4]): + cleared += 1 del cache[k] + else: + kept += 1 + log(f"Invalidated {cleared} of {cleared+kept} DB cache entries") diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index 0728192..38133f4 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -586,7 +586,7 @@ def clean_db(): delete from tracks where id not in (select track_id from scrobbles) ''')).rowcount - log(f"Deleted {a2} tracks without scrobbles ({a1} track artist entries)") + 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 @@ -595,7 +595,7 @@ def clean_db(): # delete from artists where id not in (select artist_id from trackartists) #''')).rowcount # - #log(f"Deleted {a3} artists without tracks") + #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(''' @@ -605,7 +605,7 @@ def clean_db(): delete from tracks where id not in (select track_id from trackartists) ''')).rowcount - log(f"Deleted {a5} tracks without artists ({a4} scrobbles)") + if a5+a4>0: log(f"Deleted {a5} tracks without artists ({a4} scrobbles)")