mirror of
https://github.com/krateng/maloja.git
synced 2025-06-03 17:11:13 +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
|
@waitfordb
|
||||||
def get_top_artists(dbconn=None,**keys):
|
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"]})
|
rngs = ranges(**{k:keys[k] for k in keys if k in ["since","to","within","timerange","step","stepn","trail"]})
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
for rng in rngs:
|
for rng in rngs:
|
||||||
try:
|
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"])})
|
results.append({"range":rng,"artist":res["artist"],"scrobbles":res["scrobbles"],"associated_artists":sqldb.get_associated_artists(res["artist"])})
|
||||||
except Exception:
|
except Exception:
|
||||||
results.append({"range":rng,"artist":None,"scrobbles":0})
|
results.append({"range":rng,"artist":None,"scrobbles":0})
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% import 'snippets/links.jinja' as links %}
|
{% import 'snippets/links.jinja' as links %}
|
||||||
{% import 'snippets/entityrow.jinja' as entityrow %}
|
{% 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) %}
|
{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
|
||||||
{% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %}
|
{% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %}
|
||||||
@ -12,7 +12,7 @@
|
|||||||
{% set thisrange = e.range %}
|
{% set thisrange = e.range %}
|
||||||
{% set artist = e.artist %}
|
{% set artist = e.artist %}
|
||||||
<tr>
|
<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 %}
|
{% if artist is none %}
|
||||||
<td><div></div></td>
|
<td><div></div></td>
|
||||||
@ -20,9 +20,9 @@
|
|||||||
<td class='amount'>0</td>
|
<td class='amount'>0</td>
|
||||||
<td class='bar'></td>
|
<td class='bar'></td>
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ entityrow.row(artist,counting=e.associated_artists) }}
|
{{ entityrow.row(artist,counting=([] if specialkeys.separate else e.associated_artists)) }}
|
||||||
<td class='amount'>{{ links.link_scrobbles([{'artist':artist,'timerange':thisrange,'associated':True}],amount=e.scrobbles) }}</td>
|
<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,'timerange':thisrange,'associated':True}],percent=e.scrobbles*100/maxbar) }}</td>
|
<td class='bar'> {{ links.link_scrobbles([{'artist':artist,'associated':(not specialkeys.separate),'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
{{ filterdesc.desc(filterkeys,limitkeys) }}
|
{{ filterdesc.desc(filterkeys,limitkeys) }}
|
||||||
|
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
|
{% with artistchart = True %}
|
||||||
{% include 'snippets/timeselection.jinja' %}
|
{% include 'snippets/timeselection.jinja' %}
|
||||||
|
{% endwith %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user