diff --git a/maloja/database/sqldb.py b/maloja/database/sqldb.py index d9423e4..bbe1ba2 100644 --- a/maloja/database/sqldb.py +++ b/maloja/database/sqldb.py @@ -8,6 +8,9 @@ from ..globalconf import data_dir from .dbcache import cached_wrapper +from doreah.logging import log +from doreah.regular import runhourly + ##### DB Technical @@ -555,6 +558,27 @@ def get_artist(id): +##### MAINTENANCE + +@runhourly +def clean_db(): + with engine.begin() as conn: + result1 = conn.execute(sql.text(''' + delete from trackartists where track_id in (select id from tracks where id not in (select track_id from scrobbles)) + ''')) + result2 = conn.execute(sql.text(''' + delete from tracks where id not in (select track_id from scrobbles) + ''')) + log(f"Database Cleanup... {result1.rowcount+result2.rowcount} entries removed.") + + + + + + + + + ##### AUX FUNCS diff --git a/maloja/globalconf.py b/maloja/globalconf.py index c70d541..c1d0170 100644 --- a/maloja/globalconf.py +++ b/maloja/globalconf.py @@ -188,7 +188,7 @@ malojaconfig = Configuration( "charts_display_tiles":(tp.Boolean(), "Display Chart Tiles", False), "discourage_cpu_heavy_stats":(tp.Boolean(), "Discourage CPU-heavy stats", False, "Prevent visitors from mindlessly clicking on CPU-heavy options. Does not actually disable them for malicious actors!"), "use_local_images":(tp.Boolean(), "Use Local Images", True), - "local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600), + #"local_image_rotate":(tp.Integer(), "Local Image Rotate", 3600), "timezone":(tp.Integer(), "UTC Offset", 0), "time_format":(tp.String(), "Time Format", "%d. %b %Y %I:%M %p") }