localize mood dates

This commit is contained in:
Christophe Robillard 2026-01-10 11:32:33 +01:00
parent ad1b1e1c6b
commit 13e2e49279
2 changed files with 4 additions and 5 deletions

View file

@ -16,14 +16,14 @@ class Mood < ApplicationRecord
mood_range = Mood.order(:recorded_at).where(recorded_at: (first_monday..to))
mood_range.each do |mood|
while current_date < mood.recorded_at.to_date do
log_mood << [ current_date.to_s, current_mode ]
log_mood << [ current_date, current_mode ]
current_date += 1
end
current_mode = mood.mode
end
while current_date <= to.to_date do
log_mood << [ current_date.to_s, current_mode ]
log_mood << [ current_date, current_mode ]
current_date += 1
end
log_mood.each_slice(7).to_a

View file

@ -42,15 +42,14 @@
<% @mood_log.each do |week| %>
<div class="is-flex is-flex-direction-column is-flex-wrap-wrap mb-3">
<div class="is-size-7 day">
<% day = Date.parse(week.first[0]) %>
<% day = week.first[0] %>
<% if day.day < 8 && day.monday? %>
<%= l(day, format: "%b") %>
<% end %>
</div>
<% week.each do |d| %>
<% day = Date.parse(d[0]) %>
<% if d[1] %>
<div data-image="<%= asset_path(d[1] + ".jpg") %>" data-mode="<%= d[1] %>" data-day="<%= d[0] %>" data-action="click->mood#updateDayInfo mouseover->mood#updateDayInfo mouseleave->mood#updateDayInfo" title="<%= d[0] %> : <%= d[1] %>" class="day <%= d[1] %>"></div>
<div data-image="<%= asset_path(d[1] + ".jpg") %>" data-mode="<%= d[1] %>" data-day="<%= l d[0] %>" data-action="click->mood#updateDayInfo mouseover->mood#updateDayInfo mouseleave->mood#updateDayInfo" title="<%= d[0] %> : <%= d[1] %>" class="day <%= d[1] %>"></div>
<% else %>
<div class="day"></div>
<% end %>