From 9bf0be60831a38ec09129bddfa95b160349711b0 Mon Sep 17 00:00:00 2001 From: Max Wofford Date: Wed, 12 Mar 2025 17:26:22 -0400 Subject: [PATCH] Only show logged time sentence if there is logged time! (duh) --- app/controllers/static_pages_controller.rb | 1 + app/views/static_pages/index.html.erb | 35 ++++++++++++---------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb index 1e1dfec..899bda0 100644 --- a/app/controllers/static_pages_controller.rb +++ b/app/controllers/static_pages_controller.rb @@ -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) diff --git a/app/views/static_pages/index.html.erb b/app/views/static_pages/index.html.erb index a3a0409..514eb18 100644 --- a/app/views/static_pages/index.html.erb +++ b/app/views/static_pages/index.html.erb @@ -10,23 +10,28 @@

<% 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(", ") %> ">(& <%= pluralize(@todays_languages.length - 2, 'other language') %>) - <% 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(", ") %> ">(& <%= pluralize(@todays_languages.length - 2, 'other language') %>) + <% 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 %>