dawarich/app/views/stats/index.html.erb

56 lines
2 KiB
Text
Raw Normal View History

2024-06-12 15:10:53 -04:00
<% content_for :title, 'Statistics' %>
2024-03-23 15:29:55 -04:00
<div class="w-full">
<div class="stats stats-vertical lg:stats-horizontal shadow w-full bg-base-200">
2024-03-23 16:16:11 -04:00
<div class="stat text-center">
<div class="stat-value text-primary">
2024-08-28 17:54:00 -04:00
<%= number_with_delimiter(current_user.total_distance) %> <%= DISTANCE_UNIT %>
2024-03-23 16:16:11 -04:00
</div>
<div class="stat-title">Total distance</div>
</div>
2024-03-24 13:55:35 -04:00
<div class="stat text-center">
<div class="stat-value text-success">
<%= number_with_delimiter current_user.tracked_points.count %>
2024-03-24 13:55:35 -04:00
</div>
<div class="stat-title">Geopoints tracked</div>
</div>
<% if REVERSE_GEOCODING_ENABLED %>
<%= render 'stats/reverse_geocoding_stats' %>
<% end %>
2024-03-23 16:16:11 -04:00
</div>
<%= link_to 'Update stats', stats_path, data: { 'turbo-method' => :post }, class: 'btn btn-primary mt-5' %>
2024-03-24 14:25:33 -04:00
<div class="mt-5 grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6 p-4">
<% @stats.each do |year, stats| %>
<div class="card w-full bg-base-200 shadow-xl">
<div class="card-body">
<h2 class="card-title text-<%= header_colors.sample %>">
<%= link_to year, "/stats/#{year}", class: 'underline hover:no-underline' %>
2024-05-23 14:12:23 -04:00
<%= link_to '[Map]', map_url(year_timespan(year)), class: 'underline hover:no-underline' %>
</h2>
<p>
2024-08-28 17:54:00 -04:00
<% cache [current_user, 'year_distance_stat', year], skip_digest: true do %>
<%= number_with_delimiter year_distance_stat(year, current_user) %><%= DISTANCE_UNIT %>
<% end %>
</p>
<% if REVERSE_GEOCODING_ENABLED %>
<div class="card-actions justify-end">
<%= countries_and_cities_stat_for_year(year, stats) %>
</div>
<% end %>
<%= column_chart(
2024-05-25 07:45:49 -04:00
Stat.year_distance(year, current_user),
height: '200px',
2024-08-28 17:54:00 -04:00
suffix: " #{DISTANCE_UNIT}",
xtitle: 'Days',
ytitle: 'Distance'
) %>
</div>
</div>
<% end %>
</div>
2024-03-23 15:29:55 -04:00
</div>