{% comment %}
Displays a table of number of Tweets per year.

Expects:

* user -- Optional, a single Twitter User object, to restrict counts to that.
* type -- Optional, 'tweets' (default) or 'favorites'.
{% endcomment %}

{% load ditto_twitter %}
{% load l10n %}

{% if type|default_if_none:'tweets' == 'favorites' %}
	{% if user %}
		{% annual_favorite_counts screen_name=user.screen_name as tweets %}
	{% else %}
		{% annual_favorite_counts as tweets %}
	{% endif %}
{% else %}
	{% if user %}
		{% annual_tweet_counts screen_name=user.screen_name as tweets %}
	{% else %}
		{% annual_tweet_counts as tweets %}
	{% endif %}
{% endif %}

{% if tweets %}
	<div class="card mb-3">
		<div class="card-block">
			<h2 class="h6 card-title">{% if type|default_if_none:'tweets' == 'favorites' %}Liked tweets{% else %}Tweets{% endif %} per year</h2>
			<table class="table table-sm mb-0 flickr-tweets-annual">
				<thead class="sr-only">
					<tr>
						<th>Year</th>
						<th class="text-right">Tweets</th>
					</tr>
				</thead>
				<tbody>
					{% for s in tweets %}
						<tr>
							<td>{{ s.year|unlocalize }}</td>
							<td class="text-right">{{ s.count }}</td>
						</tr>
					{% endfor %}
				</tbody>
			</table>
		</div>
	</div>
{% endif %}

