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
abf8f4ae
Commit
abf8f4ae
authored
Dec 19, 2018
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add deepest epic relation level to usage data
Send epics deepest relationship level of instance to usage ping.
parent
94b8dbbd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
0 deletions
+77
-0
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+40
-0
ee/lib/ee/gitlab/usage_data.rb
ee/lib/ee/gitlab/usage_data.rb
+9
-0
ee/spec/lib/gitlab/usage_data_spec.rb
ee/spec/lib/gitlab/usage_data_spec.rb
+7
-0
ee/spec/models/epic_spec.rb
ee/spec/models/epic_spec.rb
+21
-0
No files found.
ee/app/models/ee/epic.rb
View file @
abf8f4ae
...
...
@@ -156,6 +156,46 @@ module EE
)
end
end
# Return the deepest relation level for an epic.
# Example 1:
# epic1 - parent: nil
# epic2 - parent: epic1
# epic3 - parent: epic 2
# Returns: 3
# ------------
# Example 2:
# epic1 - parent: nil
# epic2 - parent: epic1
# Returns: 2
def
deepest_relationship_level
return
nil
unless
::
Gitlab
::
Database
.
postgresql?
result
=
ActiveRecord
::
Base
.
connection
.
execute
(
<<-
SQL
WITH RECURSIVE descendants AS (
SELECT id, 1 depth
FROM epics
WHERE parent_id IS NOT NULL
UNION
SELECT e.id, d.depth+ 1
FROM epics e
INNER JOIN descendants d
ON e.parent_id = d.id
)
SELECT MAX(depth) as deepest_level
FROM descendants
SQL
)
deepest_level
=
result
.
first
[
"deepest_level"
]
||
0
# For performance reason epics without a parent_id are being
# ignored in the query.
# So we sum 1 to the result to take into account first parent.
deepest_level
+
1
end
end
def
assignees
...
...
ee/lib/ee/gitlab/usage_data.rb
View file @
abf8f4ae
...
...
@@ -105,8 +105,17 @@ module EE
projects_with_tracing_enabled:
count
(
ProjectTracingSetting
)
}).
merge
(
service_desk_counts
).
merge
(
security_products_usage
)
# MySql does not support recursive queries so we can't retrieve epics relationship depth
if
::
Gitlab
::
Database
.
postgresql?
usage_data
[
:counts
]
=
usage_data
[
:counts
].
merge
(
epics_deepest_relationship_level
)
end
usage_data
end
def
epics_deepest_relationship_level
{
epics_deepest_relationship_level:
::
Epic
.
deepest_relationship_level
}
end
end
end
end
ee/spec/lib/gitlab/usage_data_spec.rb
View file @
abf8f4ae
...
...
@@ -54,6 +54,7 @@ describe Gitlab::UsageData do
expect
(
count_data
.
keys
).
to
include
(
*
%i(
projects_mirrored_with_pipelines_enabled
epics
epics_deepest_relationship_level
geo_nodes
ldap_group_links
ldap_keys
...
...
@@ -73,6 +74,12 @@ describe Gitlab::UsageData do
expect
(
count_data
[
:projects_with_packages
]).
to
eq
(
2
)
end
it
'gathers deepest epic relationship level'
,
:postgresql
do
count_data
=
subject
[
:counts
]
expect
(
count_data
.
keys
).
to
include
(
:epics_deepest_relationship_level
)
end
it
'gathers security products usage data'
do
count_data
=
subject
[
:counts
]
...
...
ee/spec/models/epic_spec.rb
View file @
abf8f4ae
...
...
@@ -443,6 +443,27 @@ describe Epic do
end
end
describe
'.deepest_relationship_level'
do
it
'returns the deepest relationship level between epics'
do
group_1
=
create
(
:group
)
group_2
=
create
(
:group
)
# No relationship
create
(
:epic
,
group:
group_1
)
# Two levels relationship
group_1_epic_1
=
create
(
:epic
,
group:
group_1
)
create
(
:epic
,
group:
group_1
,
parent:
group_1_epic_1
)
# Three levels relationship
group_2_epic_1
=
create
(
:epic
,
group:
group_2
)
group_2_epic_2
=
create
(
:epic
,
group:
group_2
,
parent:
group_2_epic_1
)
create
(
:epic
,
group:
group_2
,
parent:
group_2_epic_2
)
expect
(
described_class
.
deepest_relationship_level
).
to
eq
(
3
)
end
end
describe
'#issues_readable_by'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
...
...
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