Commit be3e9d52 authored by charlie ablett's avatar charlie ablett

Merge branch '344279-epic-node-openstruct' into 'master'

Fix OpenStruct use in epic_node

See merge request gitlab-org/gitlab!73935
parents cccf2b50 e1f7f314
...@@ -2560,7 +2560,6 @@ Style/OpenStructUse: ...@@ -2560,7 +2560,6 @@ Style/OpenStructUse:
Exclude: Exclude:
- 'app/finders/snippets_finder.rb' - 'app/finders/snippets_finder.rb'
- 'app/helpers/application_settings_helper.rb' - 'app/helpers/application_settings_helper.rb'
- 'ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb'
- 'ee/spec/db/production/license_spec.rb' - 'ee/spec/db/production/license_spec.rb'
- 'ee/spec/features/projects/new_project_spec.rb' - 'ee/spec/features/projects/new_project_spec.rb'
- 'ee/spec/finders/template_finder_spec.rb' - 'ee/spec/finders/template_finder_spec.rb'
......
...@@ -15,6 +15,8 @@ module Gitlab ...@@ -15,6 +15,8 @@ module Gitlab
attr_accessor :children, :calculated_count_totals, :calculated_weight_sum_totals attr_accessor :children, :calculated_count_totals, :calculated_weight_sum_totals
AggregateStruct = Struct.new(:opened_issues, :closed_issues, :opened_epics, :closed_epics)
def initialize(epic_id, flat_info_list) def initialize(epic_id, flat_info_list)
# epic aggregate records from the DB loader look like the following: # epic aggregate records from the DB loader look like the following:
# { 1 => [{iid: 1, parent_id: nil, epic_state_id: 1, issues_count: 1, issues_weight_sum: 2, issues_state_id: 2}] ... } # { 1 => [{iid: 1, parent_id: nil, epic_state_id: 1, issues_count: 1, issues_weight_sum: 2, issues_state_id: 2}] ... }
...@@ -30,21 +32,21 @@ module Gitlab ...@@ -30,21 +32,21 @@ module Gitlab
def aggregate_count def aggregate_count
strong_memoize(:count_aggregate) do strong_memoize(:count_aggregate) do
OpenStruct.new({ AggregateStruct.new(
opened_issues: sum_objects(COUNT, OPENED_ISSUE_STATE, ISSUE_TYPE), sum_objects(COUNT, OPENED_ISSUE_STATE, ISSUE_TYPE),
closed_issues: sum_objects(COUNT, CLOSED_ISSUE_STATE, ISSUE_TYPE), sum_objects(COUNT, CLOSED_ISSUE_STATE, ISSUE_TYPE),
opened_epics: sum_objects(COUNT, OPENED_EPIC_STATE, EPIC_TYPE), sum_objects(COUNT, OPENED_EPIC_STATE, EPIC_TYPE),
closed_epics: sum_objects(COUNT, CLOSED_EPIC_STATE, EPIC_TYPE) sum_objects(COUNT, CLOSED_EPIC_STATE, EPIC_TYPE)
}) )
end end
end end
def aggregate_weight_sum def aggregate_weight_sum
strong_memoize(:weight_sum_aggregate) do strong_memoize(:weight_sum_aggregate) do
OpenStruct.new({ AggregateStruct.new(
opened_issues: sum_objects(WEIGHT_SUM, OPENED_ISSUE_STATE, ISSUE_TYPE), sum_objects(WEIGHT_SUM, OPENED_ISSUE_STATE, ISSUE_TYPE),
closed_issues: sum_objects(WEIGHT_SUM, CLOSED_ISSUE_STATE, ISSUE_TYPE) sum_objects(WEIGHT_SUM, CLOSED_ISSUE_STATE, ISSUE_TYPE)
}) )
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment