mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
61 lines
2.5 KiB
Text
61 lines
2.5 KiB
Text
<% content_for :title, 'Statistics' %>
|
|
|
|
<div class="w-full my-5">
|
|
<div class="stats stats-vertical lg:stats-horizontal shadow w-full bg-base-200">
|
|
<div class="stat text-center">
|
|
<div class="stat-value text-primary">
|
|
<%= number_with_delimiter(current_user.total_distance) %> <%= current_user.safe_settings.distance_unit %>
|
|
</div>
|
|
<div class="stat-title">Total distance</div>
|
|
</div>
|
|
|
|
<div class="stat text-center">
|
|
<div class="stat-value text-success">
|
|
<%= number_with_delimiter @points_total %>
|
|
</div>
|
|
<div class="stat-title">Geopoints tracked</div>
|
|
</div>
|
|
|
|
<% if DawarichSettings.reverse_geocoding_enabled? %>
|
|
<%= render 'stats/reverse_geocoding_stats' %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<%= link_to 'Update stats', update_all_stats_path, data: { turbo_method: :put }, class: 'btn btn-primary mt-5' %>
|
|
|
|
<div class="mt-6 grid grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-2 gap-6">
|
|
<% @stats.each do |year, stats| %>
|
|
<div class="card w-full bg-base-200 shadow-xl">
|
|
<div class="card-body">
|
|
<h2 class="card-title justify-between text-<%= header_colors.sample %>">
|
|
<div>
|
|
<%= link_to year, "/stats/#{year}", class: 'underline hover:no-underline' %>
|
|
<%= link_to '[Map]', map_url(year_timespan(year)), class: 'underline hover:no-underline' %>
|
|
</div>
|
|
<div class="gap-2">
|
|
<span class='text-xs text-gray-500'>Last updated: <%= human_date(stats.first.updated_at) %></span>
|
|
<%= link_to '🔄', update_year_month_stats_path(year, :all), data: { turbo_method: :put }, class: 'text-sm text-gray-500 hover:underline' %>
|
|
</div>
|
|
</h2>
|
|
<p>
|
|
<% cache [current_user, 'year_distance_stat', year], skip_digest: true do %>
|
|
<%= number_with_delimiter year_distance_stat(year, current_user) %><%= current_user.safe_settings.distance_unit %>
|
|
<% end %>
|
|
</p>
|
|
<% if DawarichSettings.reverse_geocoding_enabled? %>
|
|
<div class="card-actions justify-end">
|
|
<%= countries_and_cities_stat_for_year(year, stats) %>
|
|
</div>
|
|
<% end %>
|
|
<%= column_chart(
|
|
Stat.year_distance(year, current_user),
|
|
height: '200px',
|
|
suffix: " #{current_user.safe_settings.distance_unit}",
|
|
xtitle: 'Days',
|
|
ytitle: 'Distance'
|
|
) %>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|