<% content_for :title, "#{@digest.year} Year in Review" %>

<%= @digest.year %> Year in Review

Your journey, by the numbers

<%= icon 'map' %> Distance Traveled
<%= distance_with_unit(@digest.distance, @distance_unit) %>

<%= distance_comparison_text(@digest.distance) %>

<% if @digest.yoy_distance_change %>

<%= yoy_change_text(@digest.yoy_distance_change) %> compared to <%= @digest.previous_year %>

<% end %>
<%= icon 'globe' %> Countries
<%= @digest.countries_count %>
<%= icon 'star' %> <%= @digest.first_time_countries.any? ? "#{@digest.first_time_countries.count} first time" : '0 first time' %>
<%= icon 'building' %> Cities
<%= @digest.cities_count %>
<%= icon 'star' %> <%= @digest.first_time_cities.any? ? "#{@digest.first_time_cities.count} first time" : '0 first time' %>
<% if @digest.first_time_countries.any? || @digest.first_time_cities.any? %>

<%= icon 'star' %> First Time Visits

<% if @digest.first_time_countries.any? %>

New Countries

<% @digest.first_time_countries.each do |country| %> <%= country %> <% end %>
<% end %> <% if @digest.first_time_cities.any? %>

New Cities

<% @digest.first_time_cities.take(10).each do |city| %> <%= city %> <% end %> <% if @digest.first_time_cities.count > 10 %> +<%= @digest.first_time_cities.count - 10 %> more <% end %>
<% end %>
<% end %> <% if @digest.monthly_distances.present? %>

<%= icon 'activity' %> Your Year, Month by Month

<%= column_chart( @digest.monthly_distances.sort_by { |month, _| month.to_i }.map { |month, distance_meters| [Date::ABBR_MONTHNAMES[month.to_i], Users::Digest.convert_distance(distance_meters.to_i, @distance_unit).round] }, height: '250px', suffix: " #{@distance_unit}", xtitle: 'Month', ytitle: 'Distance', colors: [ '#397bb5', '#5A4E9D', '#3B945E', '#7BC96F', '#FFD54F', '#FFA94D', '#FF6B6B', '#FF8C42', '#C97E4F', '#8B4513', '#5A2E2E', '#265d7d' ] ) %>
<% end %> <% if @digest.top_countries_by_time.any? %>

<%= icon 'map-pin' %> Where You Spent the Most Time

<% @digest.top_countries_by_time.take(5).each_with_index do |country, index| %>
<%= index + 1 %> <%= country_flag(country['name']) %> <%= country['name'] %>
<%= format_time_spent(country['minutes']) %>
<% end %> <% if @digest.untracked_days > 0 %>
? No tracking data
<%= pluralize(@digest.untracked_days.round, 'day') %>

<%= icon 'lightbulb' %> Track more in <%= @digest.year + 1 %> to see a fuller picture of your travels!

<% end %>
<% end %>

<%= icon 'earth' %> Countries & Cities

<% if @digest.toponyms.present? %> <% @digest.toponyms.each_with_index do |country, index| %>
<%= country_flag(country['country']) %> <%= country['country'] %> <%= pluralize(country['cities']&.length || 0, 'city') %>
<% end %> <% else %>

No location data available

<% end %>

<%= icon 'trophy' %> All-Time Stats

Countries visited
<%= @digest.total_countries_all_time %>
Cities explored
<%= @digest.total_cities_all_time %>
Total distance
<%= distance_with_unit(@digest.total_distance_all_time, @distance_unit) %>
<%= link_to users_digests_path, class: 'btn btn-outline' do %> Back to All Digests <% end %> <%= button_to users_digest_path(year: @digest.year), method: :delete, class: 'btn btn-outline btn-error', data: { turbo_confirm: "Are you sure you want to delete the #{@digest.year} digest? This cannot be undone." } do %> <%= icon 'trash-2' %> Delete <% end %>