Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in group by team #1804

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions app/services/reports/time_entries/report_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading