1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Implemented chart trend indicators

This commit is contained in:
Krateng 2020-08-23 00:30:55 +02:00
parent 3e6bcc45d5
commit 439d12d87f
4 changed files with 34 additions and 15 deletions

View File

@ -36,7 +36,7 @@
{% import 'partials/charts_artists.jinja' as charts_artists %}
{{ charts_artists.charts_artists(limitkeys,amountkeys,compare=False) }}
{{ charts_artists.charts_artists(limitkeys,amountkeys,compare=true) }}
{% import 'snippets/pagination.jinja' as pagination %}

View File

@ -36,7 +36,7 @@
{% import 'partials/charts_tracks.jinja' as charts_tracks %}
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,amountkeys,charts=charts,compare=false) }}
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,amountkeys,charts=charts,compare=true) }}
{% import 'snippets/pagination.jinja' as pagination %}

View File

@ -5,6 +5,21 @@
{% endif %}
{% if compare %}
{% if compare is true %}
{% set compare = limitkeys.timerange.next(step=-1) %}
{% endif %}
{% set prevartists = dbp.get_charts_artists(filterkeys,{'timerange':compare}) %}
{% set lastranks = {} %}
{% for a in prevartists %}
{% if lastranks.update({a.artist:a.rank}) %}{% endif %}
{% endfor %}
{% for a in charts %}
{% if a.artist in lastranks %}
{% if a.update({'last_rank':lastranks[a.artist]}) %}{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% set firstindex = amountkeys.page * amountkeys.perpage %}
@ -20,9 +35,12 @@
<!-- Rank -->
<td class="rank">{%if loop.changed(e.scrobbles) %}#{{ e.rank }}{% endif %}</td>
<!-- Rank change -->
{% if false %}
{% if e not in prevcharts %}<td class='rankup' title='New'>🆕</td>{% endif %}
{% if compare %}
{% if e.last_rank is undefined %}<td class='rankup' title='New'>🆕</td>
{% elif e.last_rank < e.rank %}<td class='rankdown' title='Down from #{{ e.last_rank }}'>↘</td>
{% elif e.last_rank > e.rank %}<td class='rankup' title='Up from #{{ e.last_rank }}'>↗</td>
{% elif e.last_rank == e.rank %}<td class='ranksame' title='Unchanged'>➡</td>
{% endif %}
{% endif %}
<!-- artist -->

View File

@ -9,14 +9,14 @@
{% endif %}
{% set prevtracks = dbp.get_charts_tracks(filterkeys,{'timerange':compare}) %}
{% set lastrank = {} %}
{% for t in charts %}
{% if lastrank.update({(t.track.artists,t.track.title):t.rank}) %}{% endif %}
{% set lastranks = {} %}
{% for t in prevtracks %}
{% if lastranks.update({"|".join(t.track.artists)+"||"+t.track.title:t.rank}) %}{% endif %}
{% endfor %}
{% for t in charts %}
{% if (t.track.artists,t.track.title) in lastrank %}
{% if t.update({'lastrank':lastrank[(t.track.artists,t.track.title)]}) %}{% endif %}
{% if "|".join(t.track.artists)+"||"+t.track.title in lastranks %}
{% if t.update({'last_rank':lastranks["|".join(t.track.artists)+"||"+t.track.title]}) %}{% endif %}
{% endif %}
{% endfor %}
{% endif %}
@ -24,9 +24,7 @@
{% set firstindex = amountkeys.page * amountkeys.perpage %}
{% set lastindex = firstindex + amountkeys.perpage %}
{% set maxbar = charts[0]['scrobbles'] if charts != [] else 0 %}
<table class='list'>
{% for e in charts %}
{% if loop.index0 >= firstindex and loop.index0 < lastindex %}
@ -34,9 +32,12 @@
<!-- Rank -->
<td class="rank">{%if loop.changed(e.scrobbles) %}#{{ e.rank }}{% endif %}</td>
<!-- Rank change -->
{% if false %}
{% if e not in prevtracks %}<td class='rankup' title='New'>🆕</td>{% endif %}
{% if compare %}
{% if e.last_rank is undefined %}<td class='rankup' title='New'>🆕</td>
{% elif e.last_rank < e.rank %}<td class='rankdown' title='Down from #{{ e.last_rank }}'>↘</td>
{% elif e.last_rank > e.rank %}<td class='rankup' title='Up from #{{ e.last_rank }}'>↗</td>
{% elif e.last_rank == e.rank %}<td class='ranksame' title='Unchanged'>➡</td>
{% endif %}
{% endif %}
<!-- artist -->