From 2e697fe0536fde0fb6c0ab1f4c2a2bb17ef7575e Mon Sep 17 00:00:00 2001 From: Kaio Magalhaes Date: Thu, 21 Mar 2024 15:45:40 -0300 Subject: [PATCH] fix time entries analytics --- app/utils/analytics/time_entries/expected_hours.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/utils/analytics/time_entries/expected_hours.rb b/app/utils/analytics/time_entries/expected_hours.rb index f48d666..bdd4200 100644 --- a/app/utils/analytics/time_entries/expected_hours.rb +++ b/app/utils/analytics/time_entries/expected_hours.rb @@ -16,8 +16,12 @@ def data end def entries - days = ([@start_date, @assignment.start_date].max..[@end_date, @assignment.end_date].min).filter do |d| - !d.sunday? && !d.saturday? + start_date = [@start_date, @assignment.start_date].max + end_date = [@end_date, @assignment.end_date].min + + # Convert the range into an array of dates + days = (start_date.to_date..end_date.to_date).to_a.select do |d| + d.wday.between?(1, 5) # Exclude Saturday (6) and Sunday (0) end days.map do |day|