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:
parent
77c4dac7be
commit
45ea7499b2
@ -588,30 +588,45 @@ def get_export(**keys):
|
|||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
def delete_scrobble(timestamp):
|
def delete_scrobble(timestamp):
|
||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
return database.remove_scrobble(timestamp)
|
result = database.remove_scrobble(timestamp)
|
||||||
|
return {
|
||||||
|
"status":"success"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@api.post("edit_artist")
|
@api.post("edit_artist")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
def edit_artist(id,name):
|
def edit_artist(id,name):
|
||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
return database.edit_artist(id,name)
|
result = database.edit_artist(id,name)
|
||||||
|
return {
|
||||||
|
"status":"success"
|
||||||
|
}
|
||||||
|
|
||||||
@api.post("edit_track")
|
@api.post("edit_track")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
def edit_track(id,title):
|
def edit_track(id,title):
|
||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
return database.edit_track(id,{'title':title})
|
result = database.edit_track(id,{'title':title})
|
||||||
|
return {
|
||||||
|
"status":"success"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@api.post("merge_tracks")
|
@api.post("merge_tracks")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
def merge_tracks(target_id,source_ids):
|
def merge_tracks(target_id,source_ids):
|
||||||
"""Internal Use Only"""
|
"""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")
|
@api.post("merge_artists")
|
||||||
@authenticated_function(api=True)
|
@authenticated_function(api=True)
|
||||||
def merge_artists(target_id,source_ids):
|
def merge_artists(target_id,source_ids):
|
||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
return database.merge_artists(target_id,source_ids)
|
result = database.merge_artists(target_id,source_ids)
|
||||||
|
return {
|
||||||
|
"status":"success"
|
||||||
|
}
|
||||||
|
@ -146,38 +146,48 @@ def remove_scrobble(timestamp):
|
|||||||
result = sqldb.delete_scrobble(timestamp)
|
result = sqldb.delete_scrobble(timestamp)
|
||||||
dbcache.invalidate_caches(timestamp)
|
dbcache.invalidate_caches(timestamp)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@waitfordb
|
@waitfordb
|
||||||
def edit_artist(id,artistinfo):
|
def edit_artist(id,artistinfo):
|
||||||
artist = sqldb.get_artist(id)
|
artist = sqldb.get_artist(id)
|
||||||
log(f"Renaming {artist} to {artistinfo}")
|
log(f"Renaming {artist} to {artistinfo}")
|
||||||
sqldb.edit_artist(id,artistinfo)
|
result = sqldb.edit_artist(id,artistinfo)
|
||||||
dbcache.invalidate_entity_cache()
|
dbcache.invalidate_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@waitfordb
|
@waitfordb
|
||||||
def edit_track(id,trackinfo):
|
def edit_track(id,trackinfo):
|
||||||
track = sqldb.get_track(id)
|
track = sqldb.get_track(id)
|
||||||
log(f"Renaming {track['title']} to {trackinfo['title']}")
|
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_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@waitfordb
|
@waitfordb
|
||||||
def merge_artists(target_id,source_ids):
|
def merge_artists(target_id,source_ids):
|
||||||
sources = [sqldb.get_artist(id) for id in source_ids]
|
sources = [sqldb.get_artist(id) for id in source_ids]
|
||||||
target = sqldb.get_artist(target_id)
|
target = sqldb.get_artist(target_id)
|
||||||
log(f"Merging {sources} into {target}")
|
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()
|
dbcache.invalidate_entity_cache()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
@waitfordb
|
@waitfordb
|
||||||
def merge_tracks(target_id,source_ids):
|
def merge_tracks(target_id,source_ids):
|
||||||
sources = [sqldb.get_track(id) for id in source_ids]
|
sources = [sqldb.get_track(id) for id in source_ids]
|
||||||
target = sqldb.get_track(target_id)
|
target = sqldb.get_track(target_id)
|
||||||
log(f"Merging {sources} into {target}")
|
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()
|
dbcache.invalidate_entity_cache()
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,7 +275,9 @@ def delete_scrobble(scrobble_id,dbconn=None):
|
|||||||
DB['scrobbles'].c.timestamp == scrobble_id
|
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
|
### 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)
|
result = dbconn.execute(op)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
@connection_provider
|
@connection_provider
|
||||||
def edit_track(id,trackdict,dbconn=None):
|
def edit_track(id,trackdict,dbconn=None):
|
||||||
dbentry = track_dict_to_db(trackdict)
|
dbentry = track_dict_to_db(trackdict)
|
||||||
@ -378,6 +382,8 @@ def edit_track(id,trackdict,dbconn=None):
|
|||||||
)
|
)
|
||||||
result = dbconn.execute(op)
|
result = dbconn.execute(op)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
### Merge
|
### Merge
|
||||||
|
|
||||||
@ -392,6 +398,8 @@ def merge_tracks(target_id,source_ids,dbconn=None):
|
|||||||
result = dbconn.execute(op)
|
result = dbconn.execute(op)
|
||||||
clean_db()
|
clean_db()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
@connection_provider
|
@connection_provider
|
||||||
def merge_artists(target_id,source_ids,dbconn=None):
|
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)
|
result = dbconn.execute(op)
|
||||||
clean_db()
|
clean_db()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Functions that get rows according to parameters
|
### Functions that get rows according to parameters
|
||||||
|
Loading…
Reference in New Issue
Block a user