fix date mixup in timeline
This commit is contained in:
parent
d29208ca83
commit
c716122b9a
@ -32,20 +32,24 @@ module TimelineHelper
|
|||||||
|
|
||||||
# weekly occupany, hash containing weeks to number of volunteer mapping
|
# weekly occupany, hash containing weeks to number of volunteer mapping
|
||||||
def weekly
|
def weekly
|
||||||
data = {}
|
|
||||||
month_start = Date.today.at_beginning_of_month
|
month_start = Date.today.at_beginning_of_month
|
||||||
( 0 ... @weeks ).each do |week|
|
( 0 ... @weeks ).collect do |week|
|
||||||
data[ week ] = -1
|
amount = -1
|
||||||
end_week = month_start + week.weeks
|
start_week = month_start + week.weeks
|
||||||
|
end_week = start_week + 7.days
|
||||||
|
#puts "WEEK #{week} #{start_week} -- #{end_week}"
|
||||||
@members.each do |mem|
|
@members.each do |mem|
|
||||||
|
puts "volunteer #{mem.name}"
|
||||||
next unless mem.arriving
|
next unless mem.arriving
|
||||||
next unless mem.leaving
|
next unless mem.leaving
|
||||||
next if mem.leaving <= end_week
|
next if mem.leaving <= start_week
|
||||||
next if mem.arriving >= (end_week - 7.days)
|
#puts "volunteer #{mem.name} leaving #{mem.leaving}"
|
||||||
data[ week ] += 1
|
next if mem.arriving >= end_week
|
||||||
|
#puts "volunteer #{mem.name} arriving #{mem.arriving}"
|
||||||
|
amount += 1
|
||||||
end
|
end
|
||||||
|
amount
|
||||||
end
|
end
|
||||||
data
|
|
||||||
end
|
end
|
||||||
def bg_for(week)
|
def bg_for(week)
|
||||||
[ "bg-cyan-100",
|
[ "bg-cyan-100",
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
%td{colspan: 7 , class: bg_for(week + 2) }
|
%td{colspan: 7 , class: bg_for(week + 2) }
|
||||||
= small_date(Date.today.at_beginning_of_month + week.weeks)
|
= small_date(Date.today.at_beginning_of_month + week.weeks)
|
||||||
%tr
|
%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
|
%td{colspan: 7, class: bg_for(week + 2) , style: "width: #{week_pixels}px;"}= amount
|
||||||
|
|
||||||
- @members.each_with_index do |member , index|
|
- @members.each_with_index do |member , index|
|
||||||
|
Loading…
Reference in New Issue
Block a user