{% import 'snippets/links.jinja' as links %}
{% import 'snippets/entityrow.jinja' as entityrow %}

{% set ranges = dbc.get_top_artists(limitkeys,delimitkeys) %}

{% set maxbar = ranges|map(attribute="scrobbles")|max|default(1) %}
{% if maxbar < 1 %}{% set maxbar = 1 %}{% endif %}

<table class="list">
	{% for e in ranges %}

	{% set thisrange = e.range %}
	{% set artist = e.artist %}
	<tr>
		<td><a href="{{ mlj_uri.create_uri("/charts_artists",{'timerange':thisrange}) }}">{{ thisrange.desc() }}</a></td>

		{% if artist is none %}
			<td><div></div></td>
			<td class='stats'>n/a</td>
			<td class='amount'>0</td>
			<td class='bar'></td>
		{% else %}
		{{ entityrow.row(artist) }}
		<td class='amount'>{{ links.link_scrobbles([{'artist':artist,'timerange':thisrange}],amount=e.scrobbles) }}</td>
		<td class='bar'> {{ links.link_scrobbles([{'artist':artist,'timerange':thisrange}],percent=e.scrobbles*100/maxbar) }}</td>
		{% endif %}

	</tr>
	{% endfor %}
</table>
