diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index 4bb4834..048f1b2 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -469,12 +469,14 @@ def get_performance(dbconn=None,**keys): @waitfordb def get_top_artists(dbconn=None,**keys): + separate = keys.get('separate') + rngs = ranges(**{k:keys[k] for k in keys if k in ["since","to","within","timerange","step","stepn","trail"]}) results = [] for rng in rngs: try: - res = get_charts_artists(timerange=rng,dbconn=dbconn)[0] + res = get_charts_artists(timerange=rng,separate=separate,dbconn=dbconn)[0] results.append({"range":rng,"artist":res["artist"],"scrobbles":res["scrobbles"],"associated_artists":sqldb.get_associated_artists(res["artist"])}) except Exception: results.append({"range":rng,"artist":None,"scrobbles":0}) diff --git a/maloja/web/jinja/partials/top_artists.jinja b/maloja/web/jinja/partials/top_artists.jinja index 1d785d1..dae0f10 100644 --- a/maloja/web/jinja/partials/top_artists.jinja +++ b/maloja/web/jinja/partials/top_artists.jinja @@ -1,7 +1,7 @@ {% import 'snippets/links.jinja' as links %} {% import 'snippets/entityrow.jinja' as entityrow %} -{% set ranges = dbc.get_top_artists(limitkeys,delimitkeys) %} +{% set ranges = dbc.get_top_artists(limitkeys,delimitkeys,specialkeys) %} {% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %} {% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %} @@ -12,7 +12,7 @@ {% set thisrange = e.range %} {% set artist = e.artist %} - {{ thisrange.desc() }} + {{ thisrange.desc() }} {% if artist is none %}
@@ -20,9 +20,9 @@ 0 {% else %} - {{ entityrow.row(artist,counting=e.associated_artists) }} - {{ links.link_scrobbles([{'artist':artist,'timerange':thisrange,'associated':True}],amount=e.scrobbles) }} - {{ links.link_scrobbles([{'artist':artist,'timerange':thisrange,'associated':True}],percent=e.scrobbles*100/maxbar) }} + {{ entityrow.row(artist,counting=([] if specialkeys.separate else e.associated_artists)) }} + {{ links.link_scrobbles([{'artist':artist,'associated':(not specialkeys.separate),'timerange':thisrange}],amount=e.scrobbles) }} + {{ links.link_scrobbles([{'artist':artist,'associated':(not specialkeys.separate),'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }} {% endif %} diff --git a/maloja/web/jinja/top_artists.jinja b/maloja/web/jinja/top_artists.jinja index ce4bf24..262963f 100644 --- a/maloja/web/jinja/top_artists.jinja +++ b/maloja/web/jinja/top_artists.jinja @@ -21,7 +21,9 @@ {{ filterdesc.desc(filterkeys,limitkeys) }}

+ {% with artistchart = True %} {% include 'snippets/timeselection.jinja' %} + {% endwith %}