diff --git a/app/views/common/_calendar.html.erb b/app/views/common/_calendar.html.erb index 882088a..70698d0 100644 --- a/app/views/common/_calendar.html.erb +++ b/app/views/common/_calendar.html.erb @@ -65,6 +65,18 @@ days.each { |d| issue_hours_by_day[d] += issue.estimated_hours.to_f / days.size } end end + + # A day's estimated hours: its share of issues plus its appointments + day_hours = lambda do |day| + issue_hours_by_day[day] + appointments_by_day.fetch(day, []).sum { |appointment, number| appointment_hours.call(appointment, number) } + end + + # Month totals: only the shown month's own days (not the neighbouring months' days that fill out the + # first and last weeks), and including weeks hidden by "Hide Past Weeks" + month_days = (calendar.startdt..calendar.enddt).select { |d| d.month == calendar.month } + monthly_total_hours = month_days.sum { |d| day_hours.call(d) } + monthly_appointment_count = month_days.flat_map { |d| appointments_by_day.fetch(d, []).map(&:first) } + .uniq.count { |a| !a.call_out? && a.counts_toward_hours? } %> <%# Calendar Status Legend Key: the statuses set up in the plugin settings, then call-outs %> @@ -88,7 +100,18 @@ <% end %> -