Only show logged time sentence if there is logged time!

(duh)
This commit is contained in:
Max Wofford
2025-03-12 17:26:22 -04:00
parent 6138b8f3c3
commit 9bf0be6083
2 changed files with 21 additions and 15 deletions

View File

@@ -37,6 +37,7 @@ class StaticPagesController < ApplicationController
@todays_languages = language_counts.map(&:first)
@todays_editors = editor_counts.map(&:first)
@show_logged_time_sentence = @todays_languages.any? || @todays_editors.any?
# Get today's leaderboard
@leaderboard = Leaderboard.find_by(start_date: Date.current, deleted_at: nil)

View File

@@ -10,23 +10,28 @@
</p>
<% end %>
<% if current_user %>
You've logged
<%= short_time_detailed current_user.heartbeats.today.duration_seconds %>
<% if @todays_languages.any? || @todays_editors.any? %>
across
<% if @todays_languages.any? %>
<% if @todays_languages.length >= 4 %>
<%= @todays_languages[0..1].join(", ") %> <span title="<%= @todays_languages[2..].join(", ") %>">(& <%= pluralize(@todays_languages.length - 2, 'other language') %>)</span>
<% else %>
<%= @todays_languages.to_sentence %>
<% if @show_logged_time_sentence %>
You've logged
<%= short_time_detailed current_user.heartbeats.today.duration_seconds %>
<% if @todays_languages.any? || @todays_editors.any? %>
across
<% if @todays_languages.any? %>
<% if @todays_languages.length >= 4 %>
<%= @todays_languages[0..1].join(", ") %> <span title="<%= @todays_languages[2..].join(", ") %>">(& <%= pluralize(@todays_languages.length - 2, 'other language') %>)</span>
<% else %>
<%= @todays_languages.to_sentence %>
<% end %>
<% end %>
<% if @todays_languages.any? && @todays_editors.any? %>
using
<% end %>
<% if @todays_editors.any? %>
<%= @todays_editors.to_sentence %>
<% end %>
<% end %>
<% if @todays_languages.any? && @todays_editors.any? %>
using
<% end %>
<% if @todays_editors.any? %>
<%= @todays_editors.to_sentence %>
<% end %>
<% else %>
No time logged today... but you can change that!
<% end %>
<% if @leaderboard %>