mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
MOOOORE PERFORMANCE!!!
This commit is contained in:
parent
d0f265d3ca
commit
0ed2cd2e35
@ -400,10 +400,12 @@ def get_charts_artists(dbconn=None,resolve_ids=True,**keys):
|
|||||||
separate = keys.get('separate',False)
|
separate = keys.get('separate',False)
|
||||||
result = sqldb.count_scrobbles_by_artist(since=since,to=to,resolve_ids=resolve_ids,associated=(not separate),dbconn=dbconn)
|
result = sqldb.count_scrobbles_by_artist(since=since,to=to,resolve_ids=resolve_ids,associated=(not separate),dbconn=dbconn)
|
||||||
|
|
||||||
map = sqldb.get_associated_artist_map([entry['artist'] for entry in result if 'artist' in entry])
|
if resolve_ids:
|
||||||
for entry in result:
|
# only add associated info if we resolve
|
||||||
if "artist" in entry:
|
map = sqldb.get_associated_artist_map(artist_ids=[entry['artist_id'] for entry in result if 'artist_id' in entry])
|
||||||
entry['associated_artists'] = map[entry['artist']]
|
for entry in result:
|
||||||
|
if "artist_id" in entry:
|
||||||
|
entry['associated_artists'] = map[entry['artist_id']]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@waitfordb
|
@waitfordb
|
||||||
|
@ -1449,8 +1449,12 @@ def get_associated_artists(*artists,resolve_ids=True,dbconn=None):
|
|||||||
|
|
||||||
@cached_wrapper
|
@cached_wrapper
|
||||||
@connection_provider
|
@connection_provider
|
||||||
def get_associated_artist_map(artists,resolve_ids=True,dbconn=None):
|
def get_associated_artist_map(artists=[],artist_ids=None,resolve_ids=True,dbconn=None):
|
||||||
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in artists]
|
|
||||||
|
ids_supplied = (artist_ids is not None)
|
||||||
|
|
||||||
|
if not ids_supplied:
|
||||||
|
artist_ids = [get_artist_id(a,dbconn=dbconn) for a in artists]
|
||||||
|
|
||||||
|
|
||||||
jointable = sql.join(
|
jointable = sql.join(
|
||||||
@ -1476,7 +1480,9 @@ def get_associated_artist_map(artists,resolve_ids=True,dbconn=None):
|
|||||||
else:
|
else:
|
||||||
artists_to_associated[row.target_artist].append(row.id)
|
artists_to_associated[row.target_artist].append(row.id)
|
||||||
|
|
||||||
artists_to_associated = {artists[artist_ids.index(k)]:v for k,v in artists_to_associated.items()}
|
if not ids_supplied:
|
||||||
|
# if we supplied the artists, we want to convert back for the result
|
||||||
|
artists_to_associated = {artists[artist_ids.index(k)]:v for k,v in artists_to_associated.items()}
|
||||||
|
|
||||||
return artists_to_associated
|
return artists_to_associated
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user