diff --git a/app/services/reports/time_entries/report_service.rb b/app/services/reports/time_entries/report_service.rb index 06c665ab69..9c5e39dac0 100644 --- a/app/services/reports/time_entries/report_service.rb +++ b/app/services/reports/time_entries/report_service.rb @@ -71,8 +71,9 @@ def group_by_total_duration group_by = params[:group_by]&.to_sym return unless [:client, :project, :team_member].include?(group_by) - filter_service = TimeEntries::Filters.new(params.slice(:date_range, :from, :to)) - where_conditions = filter_service.date_range_filter + filter_service = TimeEntries::Filters.new(params) + where_conditions = filter_service.process + where_conditions.delete(:client_id) if where_conditions.key?(:client_id) joins_clause, group_field = case group_by when :client @@ -85,8 +86,8 @@ def group_by_total_duration raise ArgumentError, "Unsupported group_by: #{group_by}" end - grouped_durations = TimesheetEntry.kept.where(where_conditions) - .joins(joins_clause) + grouped_durations = TimesheetEntry.kept.joins(joins_clause) + .where(where_conditions) .reorder("") .group(group_field) .sum(:duration)