mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Minor database improvements
This commit is contained in:
parent
bd29c1e1ba
commit
a16c24281e
@ -84,7 +84,7 @@ for tablename in DBTABLES:
|
|||||||
# actually create tables for new databases
|
# actually create tables for new databases
|
||||||
meta.create_all(engine)
|
meta.create_all(engine)
|
||||||
|
|
||||||
# upgrade database with new columns
|
# upgrade old database with new columns
|
||||||
with engine.begin() as conn:
|
with engine.begin() as conn:
|
||||||
for tablename in DBTABLES:
|
for tablename in DBTABLES:
|
||||||
info = DBTABLES[tablename]
|
info = DBTABLES[tablename]
|
||||||
@ -176,6 +176,7 @@ def tracks_db_to_dict(rows):
|
|||||||
{
|
{
|
||||||
"artists":artists[row.id],
|
"artists":artists[row.id],
|
||||||
"title":row.title,
|
"title":row.title,
|
||||||
|
#"album":
|
||||||
"length":row.length
|
"length":row.length
|
||||||
}
|
}
|
||||||
for row in rows
|
for row in rows
|
||||||
@ -571,10 +572,11 @@ def get_tracks_map(track_ids,dbconn=None):
|
|||||||
result = dbconn.execute(op).all()
|
result = dbconn.execute(op).all()
|
||||||
|
|
||||||
tracks = {}
|
tracks = {}
|
||||||
trackids = [row.id for row in result]
|
result = list(result)
|
||||||
|
# this will get a list of artistdicts in the correct order of our rows
|
||||||
trackdicts = tracks_db_to_dict(result)
|
trackdicts = tracks_db_to_dict(result)
|
||||||
for i in range(len(trackids)):
|
for row,trackdict in zip(result,trackdicts):
|
||||||
tracks[trackids[i]] = trackdicts[i]
|
tracks[row.id] = trackdict
|
||||||
return tracks
|
return tracks
|
||||||
|
|
||||||
@cached_wrapper_individual
|
@cached_wrapper_individual
|
||||||
@ -587,10 +589,11 @@ def get_artists_map(artist_ids,dbconn=None):
|
|||||||
result = dbconn.execute(op).all()
|
result = dbconn.execute(op).all()
|
||||||
|
|
||||||
artists = {}
|
artists = {}
|
||||||
artistids = [row.id for row in result]
|
result = list(result)
|
||||||
|
# this will get a list of artistdicts in the correct order of our rows
|
||||||
artistdicts = artists_db_to_dict(result)
|
artistdicts = artists_db_to_dict(result)
|
||||||
for i in range(len(artistids)):
|
for row,artistdict in zip(result,artistdicts):
|
||||||
artists[artistids[i]] = artistdicts[i]
|
artists[row.id] = artistdict
|
||||||
return artists
|
return artists
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user