Spaghetti Code

This commit is contained in:
krateng 2023-03-30 14:39:44 +02:00
parent 12b5eb0b74
commit fd5d01b728
4 changed files with 51 additions and 31 deletions

View File

@ -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 waitfordb(func):
def newfunc(*args,**kwargs): def newfunc(*args,**kwargs):

View File

@ -22,6 +22,8 @@ if malojaconfig['USE_GLOBAL_CACHE']:
@runhourly @runhourly
def maintenance(): def maintenance():
from . import AUX_MODE
if not AUX_MODE:
print_stats() print_stats()
trim_cache() trim_cache()

View File

@ -1327,6 +1327,10 @@ def search_album(searchterm,dbconn=None):
@connection_provider @connection_provider
def clean_db(dbconn=None): def clean_db(dbconn=None):
from . import AUX_MODE
if not AUX_MODE:
with SCROBBLE_LOCK:
log(f"Database Cleanup...") log(f"Database Cleanup...")
to_delete = [ to_delete = [
@ -1352,6 +1356,7 @@ def clean_db(dbconn=None):
] ]
for d in to_delete: for d in to_delete:
print(d)
selection = dbconn.execute(sql.text(f"select * {d}")) selection = dbconn.execute(sql.text(f"select * {d}"))
for row in selection.all(): for row in selection.all():
log(f"Deleting {row}") log(f"Deleting {row}")

View File

@ -21,6 +21,9 @@ outputs = {
def import_scrobbles(inputf): def import_scrobbles(inputf):
from ...database import set_aux_mode
set_aux_mode()
from ...database.sqldb import add_scrobbles from ...database.sqldb import add_scrobbles
result = { result = {