mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Spaghetti Code
This commit is contained in:
parent
12b5eb0b74
commit
fd5d01b728
@ -45,6 +45,16 @@ dbstatus = {
|
||||
}
|
||||
|
||||
|
||||
# we're running an auxiliary task that doesn't require all the random background
|
||||
# nonsense to be fired up
|
||||
# this is temporary
|
||||
# FIX YO DAMN ARCHITECTURE ALREADY
|
||||
AUX_MODE = False
|
||||
def set_aux_mode():
|
||||
global AUX_MODE
|
||||
AUX_MODE = True
|
||||
|
||||
|
||||
|
||||
def waitfordb(func):
|
||||
def newfunc(*args,**kwargs):
|
||||
|
@ -22,6 +22,8 @@ if malojaconfig['USE_GLOBAL_CACHE']:
|
||||
|
||||
@runhourly
|
||||
def maintenance():
|
||||
from . import AUX_MODE
|
||||
if not AUX_MODE:
|
||||
print_stats()
|
||||
trim_cache()
|
||||
|
||||
|
@ -1327,6 +1327,10 @@ def search_album(searchterm,dbconn=None):
|
||||
@connection_provider
|
||||
def clean_db(dbconn=None):
|
||||
|
||||
from . import AUX_MODE
|
||||
|
||||
if not AUX_MODE:
|
||||
with SCROBBLE_LOCK:
|
||||
log(f"Database Cleanup...")
|
||||
|
||||
to_delete = [
|
||||
@ -1352,6 +1356,7 @@ def clean_db(dbconn=None):
|
||||
]
|
||||
|
||||
for d in to_delete:
|
||||
print(d)
|
||||
selection = dbconn.execute(sql.text(f"select * {d}"))
|
||||
for row in selection.all():
|
||||
log(f"Deleting {row}")
|
||||
|
@ -21,6 +21,9 @@ outputs = {
|
||||
|
||||
def import_scrobbles(inputf):
|
||||
|
||||
from ...database import set_aux_mode
|
||||
set_aux_mode()
|
||||
|
||||
from ...database.sqldb import add_scrobbles
|
||||
|
||||
result = {
|
||||
|
Loading…
Reference in New Issue
Block a user