mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Implemented experimental merging server-side
This commit is contained in:
parent
57e66fdafd
commit
ea6d70a650
@ -1 +1,2 @@
|
|||||||
- "[Feature] Can now edit track titles and artist names from web interface"
|
- "[Feature] Implemented track title and artist name editing from web interface"
|
||||||
|
- "[Feature] Implemented track and artist merging from web interface"
|
||||||
|
@ -602,3 +602,16 @@ def edit_artist(id,name):
|
|||||||
def edit_track(id,title):
|
def edit_track(id,title):
|
||||||
"""Internal Use Only"""
|
"""Internal Use Only"""
|
||||||
return database.edit_track(id,{'title':title})
|
return database.edit_track(id,{'title':title})
|
||||||
|
|
||||||
|
|
||||||
|
@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)
|
||||||
|
|
||||||
|
@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)
|
||||||
|
@ -162,7 +162,21 @@ def edit_track(id,trackinfo):
|
|||||||
dbcache.invalidate_entity_cache()
|
dbcache.invalidate_entity_cache()
|
||||||
dbcache.invalidate_caches()
|
dbcache.invalidate_caches()
|
||||||
|
|
||||||
|
@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)
|
||||||
|
dbcache.invalidate_entity_cache()
|
||||||
|
|
||||||
|
@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)
|
||||||
|
dbcache.invalidate_entity_cache()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,6 +379,31 @@ def edit_track(id,trackdict,dbconn=None):
|
|||||||
result = dbconn.execute(op)
|
result = dbconn.execute(op)
|
||||||
|
|
||||||
|
|
||||||
|
### Merge
|
||||||
|
|
||||||
|
@connection_provider
|
||||||
|
def merge_tracks(target_id,source_ids,dbconn=None):
|
||||||
|
|
||||||
|
op = DB['scrobbles'].update().where(
|
||||||
|
DB['scrobbles'].c.track_id.in_(source_ids)
|
||||||
|
).values(
|
||||||
|
track_id=target_id
|
||||||
|
)
|
||||||
|
result = dbconn.execute(op)
|
||||||
|
clean_db()
|
||||||
|
|
||||||
|
@connection_provider
|
||||||
|
def merge_artists(target_id,source_ids,dbconn=None):
|
||||||
|
|
||||||
|
op = DB['trackartists'].update().where(
|
||||||
|
DB['trackartists'].c.artist_id.in_(source_ids)
|
||||||
|
).values(
|
||||||
|
artist_id=target_id
|
||||||
|
)
|
||||||
|
result = dbconn.execute(op)
|
||||||
|
clean_db()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### Functions that get rows according to parameters
|
### Functions that get rows according to parameters
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user