mirror of
https://github.com/krateng/maloja.git
synced 2025-05-31 15:49:23 +03:00
Extended chart separation logic to performance
This commit is contained in:
parent
b9242d843e
commit
87b6250367
@ -425,6 +425,8 @@ def get_pulse(dbconn=None,**keys):
|
||||
@waitfordb
|
||||
def get_performance(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 = []
|
||||
|
||||
@ -443,7 +445,7 @@ def get_performance(dbconn=None,**keys):
|
||||
#artist = sqldb.get_artist(artist_id,dbconn=dbconn)
|
||||
# ^this is the most useless line in programming history
|
||||
# but I like consistency
|
||||
charts = get_charts_artists(timerange=rng,resolve_ids=False,dbconn=dbconn)
|
||||
charts = get_charts_artists(timerange=rng,resolve_ids=False,separate=separate,dbconn=dbconn)
|
||||
rank = None
|
||||
for c in charts:
|
||||
if c["artist_id"] == artist_id:
|
||||
|
@ -1,6 +1,6 @@
|
||||
{% import 'snippets/links.jinja' as links %}
|
||||
|
||||
{% set ranges = dbc.get_performance(filterkeys,limitkeys,delimitkeys) %}
|
||||
{% set ranges = dbc.get_performance(filterkeys,limitkeys,delimitkeys,specialkeys) %}
|
||||
|
||||
{% set minrank = ranges|map(attribute="rank")|reject("none")|max|default(60) %}
|
||||
{% set minrank = minrank + 20 %}
|
||||
@ -13,11 +13,11 @@
|
||||
<tr>
|
||||
<td class="timerange">{{ thisrange.desc() }}</td>
|
||||
<td class="rank">
|
||||
{{ links.link_rank(filterkeys,thisrange,rank=t.rank) }}
|
||||
{{ links.link_rank(filterkeys,specialkeys,thisrange,rank=t.rank) }}
|
||||
</td>
|
||||
<td class="chart">
|
||||
{% set prct = ((minrank+1-t.rank)*100/minrank if t.rank is not none else 0) %}
|
||||
{{ links.link_rank(filterkeys,thisrange,percent=prct,rank=t.rank) }}
|
||||
{{ links.link_rank(filterkeys,specialkeys,thisrange,percent=prct,rank=t.rank) }}
|
||||
</td>
|
||||
|
||||
|
||||
|
@ -25,7 +25,9 @@
|
||||
<br/>
|
||||
{{ filterdesc.desc(filterkeys,limitkeys,prefix='of') }}
|
||||
<br/><br/>
|
||||
{% with artistchart = True %}
|
||||
{% include 'snippets/timeselection.jinja' %}
|
||||
{% endwith %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -45,14 +45,14 @@
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro link_rank(filterkeys,timerange,rank=None,percent=None) %}
|
||||
{% macro link_rank(filterkeys,specialkeys,timerange,rank=None,percent=None) %}
|
||||
|
||||
{% if 'track' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_tracks",{'timerange':timerange}) %}
|
||||
{% elif 'album' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_albums",{'timerange':timerange}) %}
|
||||
{% elif 'artist' in filterkeys %}
|
||||
{% set url = mlj_uri.create_uri("/charts_artists",{'timerange':timerange}) %}
|
||||
{% set url = mlj_uri.create_uri("/charts_artists",{'timerange':timerange},specialkeys) %}
|
||||
{% endif %}
|
||||
|
||||
{% set rankclass = {1:'gold',2:'silver',3:'bronze'}[rank] or "" %}
|
||||
|
@ -62,7 +62,9 @@
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if 'artist' in filterkeys %}
|
||||
<!-- we do this only for things filtered by artist (to include or not include their subunits etc), but NOT for get_performance
|
||||
since it's more intuitive to fall under the separate/combined logic below -->
|
||||
{% if ('artist' in filterkeys) and (not artistchart) %}
|
||||
<div>
|
||||
{% for o in xassociated %}
|
||||
{% if o.replacekeys | map('compare_key_in_dicts',o.replacekeys,allkeys) | alltrue %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user