<% content_for :title, 'Statistics' %>
<%= number_with_delimiter(current_user.total_distance) %> <%= DISTANCE_UNIT %>
Total distance
<%= number_with_delimiter @points_total %>
Geopoints tracked
<% if DawarichSettings.reverse_geocoding_enabled? %> <%= render 'stats/reverse_geocoding_stats' %> <% end %>
<%= link_to 'Update stats', update_all_stats_path, data: { turbo_method: :put }, class: 'btn btn-primary mt-5' %>
<% @stats.each do |year, stats| %>

<%= link_to year, "/stats/#{year}", class: 'underline hover:no-underline' %> <%= link_to '[Map]', map_url(year_timespan(year)), class: 'underline hover:no-underline' %>
<%= link_to '[Update]', update_year_month_stats_path(year, :all), data: { turbo_method: :put }, class: 'text-sm text-gray-500 hover:underline' %>

<% cache [current_user, 'year_distance_stat', year], skip_digest: true do %> <%= number_with_delimiter year_distance_stat(year, current_user) %><%= DISTANCE_UNIT %> <% end %>

<% if DawarichSettings.reverse_geocoding_enabled? %>
<%= countries_and_cities_stat_for_year(year, stats) %>
<% end %> <%= column_chart( Stat.year_distance(year, current_user), height: '200px', suffix: " #{DISTANCE_UNIT}", xtitle: 'Days', ytitle: 'Distance' ) %>
<% end %>