fix weekly

This commit is contained in:
Torsten 2023-07-11 09:25:54 +03:00
parent 2a7582211e
commit 0cd973f6a6
1 changed files with 7 additions and 7 deletions

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