fix weekly

This commit is contained in:
Torsten 2023-07-11 09:26:11 +03:00
parent 1b44e9464f
commit d29208ca83

View File

@ -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