Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
3752f266
Commit
3752f266
authored
Mar 04, 2020
by
charlieablett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use children rather than child_ids
- Direct children
parent
9cd77158
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
20 deletions
+29
-20
ee/app/graphql/types/epic_type.rb
ee/app/graphql/types/epic_type.rb
+0
-6
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
+17
-6
ee/lib/gitlab/graphql/aggregations/epics/lazy_epic_aggregate.rb
.../gitlab/graphql/aggregations/epics/lazy_epic_aggregate.rb
+7
-3
ee/spec/graphql/types/epic_type_spec.rb
ee/spec/graphql/types/epic_type_spec.rb
+1
-1
ee/spec/lib/gitlab/graphql/aggregations/epics/epic_node_spec.rb
...c/lib/gitlab/graphql/aggregations/epics/epic_node_spec.rb
+3
-3
ee/spec/lib/gitlab/graphql/aggregations/epics/lazy_epic_aggregate_spec.rb
...ab/graphql/aggregations/epics/lazy_epic_aggregate_spec.rb
+1
-1
No files found.
ee/app/graphql/types/epic_type.rb
View file @
3752f266
...
...
@@ -138,11 +138,5 @@ module Types
resolve:
->
(
epic
,
args
,
ctx
)
do
Gitlab
::
Graphql
::
Aggregations
::
Epics
::
LazyEpicAggregate
.
new
(
ctx
,
epic
.
id
,
WEIGHT_SUM
)
end
field
:health_status
,
::
Types
::
HealthStatusEnum
,
null:
true
,
description:
'Current health status'
,
feature_flag: :save_issuable_health_status
end
end
ee/lib/gitlab/graphql/aggregations/epics/epic_node.rb
View file @
3752f266
...
...
@@ -14,7 +14,7 @@ module Gitlab
:direct_count_totals
,
:direct_weight_sum_totals
,
# only counts/weights of direct issues and child epic counts
:count_aggregate
,
:weight_sum_aggregate
attr_accessor
:child
_ids
,
:calculated_count_totals
,
:calculated_weight_sum_totals
attr_accessor
:child
ren
,
:calculated_count_totals
,
:calculated_weight_sum_totals
def
initialize
(
epic_id
,
flat_info_list
)
# epic aggregate records from the DB loader look like the following:
...
...
@@ -23,7 +23,7 @@ module Gitlab
# so in order to get a sum of the entire tree, we have to add that up recursively
@epic_id
=
epic_id
@epic_info_flat_list
=
flat_info_list
@child
_ids
=
[]
@child
ren
=
[]
@direct_count_totals
=
[]
@direct_weight_sum_totals
=
[]
...
...
@@ -43,7 +43,7 @@ module Gitlab
end
end
def
assemble_epic_totals
(
children
)
def
assemble_epic_totals
[
OPENED_EPIC_STATE
,
CLOSED_EPIC_STATE
].
each
do
|
epic_state
|
create_sum_if_needed
(
COUNT
,
epic_state
,
EPIC_TYPE
,
children
.
select
{
|
node
|
node
.
epic_state_id
==
epic_state
}.
count
)
end
...
...
@@ -91,9 +91,7 @@ module Gitlab
return
calculated_totals
(
facet
)
if
calculated_totals
(
facet
)
sum_total
=
[]
child_ids
.
each
do
|
child_id
|
child
=
tree
[
child_id
]
# get the child's totals, add to your own
children
.
each
do
|
child
|
child_sums
=
child
.
calculate_recursive_sums
(
facet
,
tree
)
sum_total
.
concat
(
child_sums
)
end
...
...
@@ -101,6 +99,19 @@ module Gitlab
set_calculated_total
(
facet
,
sum_total
)
end
def
inspect
{
epic_id:
@epic_id
,
parent_id:
@parent_id
,
direct_count_totals:
direct_count_totals
,
direct_weight_sum_totals:
direct_weight_sum_totals
,
children:
children
,
object_id:
object_id
}.
to_json
end
alias_method
:to_s
,
:inspect
private
def
sum_objects
(
facet
,
state
,
type
)
...
...
ee/lib/gitlab/graphql/aggregations/epics/lazy_epic_aggregate.rb
View file @
3752f266
...
...
@@ -87,10 +87,14 @@ module Gitlab
def
assemble_direct_child_totals
tree
.
each
do
|
_
,
node
|
node_children
=
tree
.
select
{
|
_
,
child_node
|
node
.
epic_id
==
child_node
.
parent_id
}
node
.
child_ids
=
node_children
.
keys
node
.
assemble_epic_totals
(
node_children
.
values
)
parent
=
tree
[
node
.
parent_id
]
next
if
parent
.
nil?
parent
.
children
<<
node
end
tree
.
each
do
|
_
,
node
|
node
.
assemble_epic_totals
node
.
assemble_issue_totals
end
end
...
...
ee/spec/graphql/types/epic_type_spec.rb
View file @
3752f266
...
...
@@ -11,7 +11,7 @@ describe GitlabSchema.types['Epic'] do
closed_at created_at updated_at children has_children has_issues
web_path web_url relation_path reference issues user_permissions
notes discussions relative_position subscribed participants
descendant_counts descendant_weight_sum upvotes downvotes
health_status
descendant_counts descendant_weight_sum upvotes downvotes
]
end
...
...
ee/spec/lib/gitlab/graphql/aggregations/epics/epic_node_spec.rb
View file @
3752f266
...
...
@@ -110,11 +110,11 @@ describe Gitlab::Graphql::Aggregations::Epics::EpicNode do
let!
(
:child_epic_node
)
{
described_class
.
new
(
child_epic_id
,
[{
parent_id:
epic_id
,
epic_state_id:
CLOSED_EPIC_STATE
}])
}
before
do
subject
.
child
_ids
<<
child_epic_id
subject
.
child
ren
<<
child_epic_node
end
it
'adds up the number of the child epics'
do
subject
.
assemble_epic_totals
([
child_epic_node
])
subject
.
assemble_epic_totals
expect
(
subject
).
to
have_direct_total
(
EPIC_TYPE
,
COUNT_FACET
,
CLOSED_EPIC_STATE
,
1
)
end
...
...
@@ -191,7 +191,7 @@ describe Gitlab::Graphql::Aggregations::Epics::EpicNode do
let
(
:immediate_weight_sum_totals
)
{
[]
}
before
do
subject
.
child
_ids
<<
child_epic_id
subject
.
child
ren
<<
child_epic_node
allow
(
child_epic_node
).
to
receive
(
:direct_totals
).
with
(
COUNT_FACET
).
and_return
(
child_count_totals
)
allow
(
child_epic_node
).
to
receive
(
:direct_totals
).
with
(
WEIGHT_SUM_FACET
).
and_return
(
child_weight_sum_totals
)
end
...
...
ee/spec/lib/gitlab/graphql/aggregations/epics/lazy_epic_aggregate_spec.rb
View file @
3752f266
...
...
@@ -98,7 +98,7 @@ describe Gitlab::Graphql::Aggregations::Epics::LazyEpicAggregate do
tree
=
lazy_state
[
:tree
]
expect
(
tree
[
child_epic_id
].
parent_id
).
to
eq
epic_id
expect
(
tree
[
epic_id
].
child
_ids
).
to
match_array
([
child_epic_id
])
expect
(
tree
[
epic_id
].
child
ren
.
map
(
&
:epic_id
)
).
to
match_array
([
child_epic_id
])
end
context
'for a parent-child relationship'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment