diff --git a/app/models/query/results/sums.rb b/app/models/query/results/sums.rb index 6da74e8cfba6..3eaf4dec7cca 100644 --- a/app/models/query/results/sums.rb +++ b/app/models/query/results/sums.rb @@ -42,7 +42,13 @@ def all_total_sums def all_group_sums return nil unless query.grouped? - sums_by_id = sums_select(true).inject({}) do |result, group_sum| + transform_group_keys(sums_by_group_id) + end + + private + + def sums_by_group_id + sums_select(true).inject({}) do |result, group_sum| result[group_sum["group_id"]] = {} query.summed_up_columns.each do |column| @@ -51,12 +57,8 @@ def all_group_sums result end - - transform_group_keys(sums_by_id) end - private - def sums_select(grouped = false) select = if grouped ["work_packages.group_id"]