mirror of
https://github.com/krateng/maloja.git
synced 2025-04-18 17:47:37 +03:00
Extended chart separation logic to top_artists
This commit is contained in:
parent
87b6250367
commit
090aee3cf7
@ -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})
|
||||
|
@ -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 %}
|
||||
<tr>
|
||||
<td><a href="{{ mlj_uri.create_uri("/charts_artists",{'timerange':thisrange}) }}">{{ thisrange.desc() }}</a></td>
|
||||
<td><a href="{{ mlj_uri.create_uri("/charts_artists",{'timerange':thisrange},specialkeys) }}">{{ thisrange.desc() }}</a></td>
|
||||
|
||||
{% if artist is none %}
|
||||
<td><div></div></td>
|
||||
@ -20,9 +20,9 @@
|
||||
<td class='amount'>0</td>
|
||||
<td class='bar'></td>
|
||||
{% else %}
|
||||
{{ entityrow.row(artist,counting=e.associated_artists) }}
|
||||
<td class='amount'>{{ links.link_scrobbles([{'artist':artist,'timerange':thisrange,'associated':True}],amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ links.link_scrobbles([{'artist':artist,'timerange':thisrange,'associated':True}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{{ entityrow.row(artist,counting=([] if specialkeys.separate else e.associated_artists)) }}
|
||||
<td class='amount'>{{ links.link_scrobbles([{'artist':artist,'associated':(not specialkeys.separate),'timerange':thisrange}],amount=e.scrobbles) }}</td>
|
||||
<td class='bar'> {{ links.link_scrobbles([{'artist':artist,'associated':(not specialkeys.separate),'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||
{% endif %}
|
||||
|
||||
</tr>
|
||||
|
@ -21,7 +21,9 @@
|
||||
{{ filterdesc.desc(filterkeys,limitkeys) }}
|
||||
|
||||
<br/><br/>
|
||||
{% with artistchart = True %}
|
||||
{% include 'snippets/timeselection.jinja' %}
|
||||
{% endwith %}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user