Implemented scrobble deletion

This commit is contained in:
krateng 2022-04-07 20:37:46 +02:00
parent 8d111b6de7
commit a142804bfe
4 changed files with 18 additions and 1 deletions

View File

@ -403,4 +403,4 @@ def get_export(**keys):
@api.post("delete_scrobble")
@authenticated_api
def delete_scrobble(timestamp):
pass
database.remove_scrobble(timestamp)

View File

@ -133,6 +133,11 @@ def incoming_scrobble(rawscrobble,fix=True,client=None,api=None,dbconn=None):
@waitfordb
def remove_scrobble(timestamp):
result = sqldb.delete_scrobble(timestamp)
dbcache.invalidate_caches(timestamp)

View File

@ -266,6 +266,16 @@ def add_scrobbles(scrobbleslist,dbconn=None):
if errors > 0: log(f"{errors} Scrobbles have not been written to database!",color='red')
return success,errors
@connection_provider
def delete_scrobble(scrobble_id,dbconn=None):
with SCROBBLE_LOCK:
op = DB['scrobbles'].delete().where(
DB['scrobbles'].c.timestamp == scrobble_id
)
dbconn.execute(op)
### these will 'get' the ID of an entity, creating it if necessary

View File

@ -7,4 +7,6 @@ function toggleDeleteConfirm(element) {
function deleteScrobble(id,element) {
element.parentElement.parentElement.parentElement.classList.add('removed');
neo.xhttpreq("/apis/mlj_1/delete_scrobble",data={'timestamp':id},method="POST",callback=(()=>null),json=true);
}