fix date mixup in timeline

This commit is contained in:
Torsten 2023-07-11 13:46:58 +03:00
parent d29208ca83
commit c716122b9a
2 changed files with 13 additions and 9 deletions

View File

@ -32,20 +32,24 @@ module TimelineHelper
# weekly occupany, hash containing weeks to number of volunteer mapping
def weekly
data = {}
month_start = Date.today.at_beginning_of_month
( 0 ... @weeks ).each do |week|
data[ week ] = -1
end_week = month_start + week.weeks
( 0 ... @weeks ).collect do |week|
amount = -1
start_week = month_start + week.weeks
end_week = start_week + 7.days
#puts "WEEK #{week} #{start_week} -- #{end_week}"
@members.each do |mem|
puts "volunteer #{mem.name}"
next unless mem.arriving
next unless mem.leaving
next if mem.leaving <= end_week
next if mem.arriving >= (end_week - 7.days)
data[ week ] += 1
next if mem.leaving <= start_week
#puts "volunteer #{mem.name} leaving #{mem.leaving}"
next if mem.arriving >= end_week
#puts "volunteer #{mem.name} arriving #{mem.arriving}"
amount += 1
end
amount
end
data
end
def bg_for(week)
[ "bg-cyan-100",

View File

@ -12,7 +12,7 @@
%td{colspan: 7 , class: bg_for(week + 2) }
= small_date(Date.today.at_beginning_of_month + week.weeks)
%tr
- weekly.each do |week , amount|
- weekly.each_with_index do |amount , week |
%td{colspan: 7, class: bg_for(week + 2) , style: "width: #{week_pixels}px;"}= amount
- @members.each_with_index do |member , index|