mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added regular database cleanup
This commit is contained in:
parent
7e62ddebf6
commit
ef594c2546
@ -8,6 +8,9 @@ from ..globalconf import data_dir
|
|||||||
|
|
||||||
from .dbcache import cached_wrapper
|
from .dbcache import cached_wrapper
|
||||||
|
|
||||||
|
from doreah.logging import log
|
||||||
|
from doreah.regular import runhourly
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##### DB Technical
|
##### 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
|
##### AUX FUNCS
|
||||||
|
@ -188,7 +188,7 @@ malojaconfig = Configuration(
|
|||||||
"charts_display_tiles":(tp.Boolean(), "Display Chart Tiles", False),
|
"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!"),
|
"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),
|
"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),
|
"timezone":(tp.Integer(), "UTC Offset", 0),
|
||||||
"time_format":(tp.String(), "Time Format", "%d. %b %Y %I:%M %p")
|
"time_format":(tp.String(), "Time Format", "%d. %b %Y %I:%M %p")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user