Skip to content

Commit

Permalink
fix columns used in summing
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed Oct 15, 2024
1 parent 552033d commit cb1f5af
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ def self.scoped_column_sum(scope, select, grouped:, query:)
scope = scope.except(:order, :select)

if grouped
group_by = query.group_by_statement

scope
.joins(query.group_by_join_statement)
.group(group_by)
.select(select_group_by(group_by), select)
.group(query.group_by_statement)
.select(select_group_by(query.group_by_select), select)
else
scope
.select(select)
Expand Down
2 changes: 1 addition & 1 deletion app/models/query/results/sums.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def sums_callable_joins(grouped)
def sums_work_package_scope_selects(grouped)
group_statement =
if grouped
[Queries::WorkPackages::Selects::WorkPackageSelect.select_group_by(query.group_by_statement)]
[Queries::WorkPackages::Selects::WorkPackageSelect.select_group_by(query.group_by_select)]
else
[]
end
Expand Down
2 changes: 2 additions & 0 deletions modules/costs/spec/lib/costs/query_currency_select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
allow(query).to receive_messages(
results: result,
group_by_join_statement: nil,
group_by_select: "author_id",
group_by_statement: "author_id"
)

Expand Down Expand Up @@ -130,6 +131,7 @@
allow(query).to receive_messages(
results: result,
group_by_join_statement: nil,
group_by_select: "author_id",
group_by_statement: "author_id"
)

Expand Down

0 comments on commit cb1f5af

Please sign in to comment.