fix weekly
This commit is contained in:
parent
2a7582211e
commit
0cd973f6a6
@ -29,21 +29,21 @@ module TimelineHelper
|
||||
max = max_days - started_days(member)
|
||||
distance > max ? max : distance
|
||||
end
|
||||
|
||||
# weekly occupany, hash containing weeks to number of volunteer mapping
|
||||
def weekly
|
||||
data = {}
|
||||
week = 0
|
||||
while( week < @weeks ) do
|
||||
month_start = Date.today.at_beginning_of_month
|
||||
( 0 ... @weeks ).each do |week|
|
||||
data[ week ] = -1
|
||||
start_week = Date.today.at_beginning_of_month + week.weeks
|
||||
end_week = Date.today.at_beginning_of_month + (week + 1).weeks
|
||||
end_week = month_start + week.weeks
|
||||
@members.each do |mem|
|
||||
next unless mem.arriving
|
||||
next unless mem.leaving
|
||||
next if mem.arriving > start_week
|
||||
next if mem.leaving < end_week
|
||||
next if mem.leaving <= end_week
|
||||
next if mem.arriving >= (end_week - 7.days)
|
||||
data[ week ] += 1
|
||||
end
|
||||
week += 1
|
||||
end
|
||||
data
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user