1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added some return values to database

This commit is contained in:
krateng 2022-04-17 20:18:26 +02:00
parent 77c4dac7be
commit 45ea7499b2
3 changed files with 45 additions and 10 deletions

View File

@ -588,30 +588,45 @@ def get_export(**keys):
@authenticated_function(api=True)
def delete_scrobble(timestamp):
"""Internal Use Only"""
return database.remove_scrobble(timestamp)
result = database.remove_scrobble(timestamp)
return {
"status":"success"
}
@api.post("edit_artist")
@authenticated_function(api=True)
def edit_artist(id,name):
"""Internal Use Only"""
return database.edit_artist(id,name)
result = database.edit_artist(id,name)
return {
"status":"success"
}
@api.post("edit_track")
@authenticated_function(api=True)
def edit_track(id,title):
"""Internal Use Only"""
return database.edit_track(id,{'title':title})
result = database.edit_track(id,{'title':title})
return {
"status":"success"
}
@api.post("merge_tracks")
@authenticated_function(api=True)
def merge_tracks(target_id,source_ids):
"""Internal Use Only"""
return database.merge_tracks(target_id,source_ids)
result = database.merge_tracks(target_id,source_ids)
return {
"status":"success"
}
@api.post("merge_artists")
@authenticated_function(api=True)
def merge_artists(target_id,source_ids):
"""Internal Use Only"""
return database.merge_artists(target_id,source_ids)
result = database.merge_artists(target_id,source_ids)
return {
"status":"success"
}

View File

@ -146,38 +146,48 @@ def remove_scrobble(timestamp):
result = sqldb.delete_scrobble(timestamp)
dbcache.invalidate_caches(timestamp)
return result
@waitfordb
def edit_artist(id,artistinfo):
artist = sqldb.get_artist(id)
log(f"Renaming {artist} to {artistinfo}")
sqldb.edit_artist(id,artistinfo)
result = sqldb.edit_artist(id,artistinfo)
dbcache.invalidate_entity_cache()
dbcache.invalidate_caches()
return result
@waitfordb
def edit_track(id,trackinfo):
track = sqldb.get_track(id)
log(f"Renaming {track['title']} to {trackinfo['title']}")
sqldb.edit_track(id,trackinfo)
result = sqldb.edit_track(id,trackinfo)
dbcache.invalidate_entity_cache()
dbcache.invalidate_caches()
return result
@waitfordb
def merge_artists(target_id,source_ids):
sources = [sqldb.get_artist(id) for id in source_ids]
target = sqldb.get_artist(target_id)
log(f"Merging {sources} into {target}")
sqldb.merge_artists(target_id,source_ids)
result = sqldb.merge_artists(target_id,source_ids)
dbcache.invalidate_entity_cache()
return result
@waitfordb
def merge_tracks(target_id,source_ids):
sources = [sqldb.get_track(id) for id in source_ids]
target = sqldb.get_track(target_id)
log(f"Merging {sources} into {target}")
sqldb.merge_tracks(target_id,source_ids)
result = sqldb.merge_tracks(target_id,source_ids)
dbcache.invalidate_entity_cache()
return result

View File

@ -275,7 +275,9 @@ def delete_scrobble(scrobble_id,dbconn=None):
DB['scrobbles'].c.timestamp == scrobble_id
)
dbconn.execute(op)
result = dbconn.execute(op)
return True
### these will 'get' the ID of an entity, creating it if necessary
@ -367,6 +369,8 @@ def edit_artist(id,artistdict,dbconn=None):
)
result = dbconn.execute(op)
return True
@connection_provider
def edit_track(id,trackdict,dbconn=None):
dbentry = track_dict_to_db(trackdict)
@ -378,6 +382,8 @@ def edit_track(id,trackdict,dbconn=None):
)
result = dbconn.execute(op)
return True
### Merge
@ -392,6 +398,8 @@ def merge_tracks(target_id,source_ids,dbconn=None):
result = dbconn.execute(op)
clean_db()
return True
@connection_provider
def merge_artists(target_id,source_ids,dbconn=None):
@ -403,6 +411,8 @@ def merge_artists(target_id,source_ids,dbconn=None):
result = dbconn.execute(op)
clean_db()
return True
### Functions that get rows according to parameters