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
569a4bf4
Commit
569a4bf4
authored
May 14, 2020
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add endpoint for time summary to VSA
parent
f35bf8cb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
9 deletions
+59
-9
ee/app/controllers/analytics/cycle_analytics/summary_controller.rb
...ntrollers/analytics/cycle_analytics/summary_controller.rb
+13
-4
ee/app/models/analytics/cycle_analytics/group_level.rb
ee/app/models/analytics/cycle_analytics/group_level.rb
+9
-2
ee/config/routes/analytics.rb
ee/config/routes/analytics.rb
+1
-0
ee/config/routes/group.rb
ee/config/routes/group.rb
+1
-0
ee/spec/controllers/analytics/cycle_analytics/summary_controller_spec.rb
...lers/analytics/cycle_analytics/summary_controller_spec.rb
+13
-3
ee/spec/models/analytics/cycle_analytics/group_level_spec.rb
ee/spec/models/analytics/cycle_analytics/group_level_spec.rb
+22
-0
No files found.
ee/app/controllers/analytics/cycle_analytics/summary_controller.rb
View file @
569a4bf4
...
...
@@ -8,18 +8,23 @@ module Analytics
check_feature_flag
Gitlab
::
Analytics
::
CYCLE_ANALYTICS_FEATURE_FLAG
before_action
:load_group
before_action
:authorize_access
before_action
:validate_params
def
show
return
render_403
unless
can?
(
current_user
,
:read_group_cycle_analytics
,
@group
)
group_level
=
GroupLevel
.
new
(
group:
@group
,
options:
options
(
group_params
))
render
json:
group_level
.
summary
end
def
time_summary
render
json:
group_level
.
time_summary
end
private
def
group_level
@group_level
||=
GroupLevel
.
new
(
group:
@group
,
options:
options
(
group_params
))
end
def
group_params
hash
=
{
created_after:
request_params
.
created_after
,
created_before:
request_params
.
created_before
}
hash
[
:project_ids
]
=
request_params
.
project_ids
if
request_params
.
project_ids
.
any?
...
...
@@ -42,6 +47,10 @@ module Analytics
def
allowed_params
params
.
permit
(
:created_after
,
:created_before
,
project_ids:
[])
end
def
authorize_access
return
render_403
unless
can?
(
current_user
,
:read_group_cycle_analytics
,
@group
)
end
end
end
end
ee/app/models/analytics/cycle_analytics/group_level.rb
View file @
569a4bf4
...
...
@@ -15,8 +15,15 @@ module Analytics
def
summary
@summary
||=
Gitlab
::
Analytics
::
CycleAnalytics
::
Summary
::
Group
::
StageSummary
.
new
(
group
,
options:
options
)
.
data
.
new
(
group
,
options:
options
)
.
data
end
def
time_summary
@time_summary
||=
Gitlab
::
Analytics
::
CycleAnalytics
::
GroupStageTimeSummary
.
new
(
group
,
options:
options
)
.
data
end
def
permissions
(
*
)
...
...
ee/config/routes/analytics.rb
View file @
569a4bf4
...
...
@@ -14,6 +14,7 @@ namespace :analytics do
end
end
resource
:summary
,
controller: :summary
,
only: :show
get
'/time_summary'
=>
'summary#time_summary'
end
get
'/cycle_analytics'
,
to:
redirect
(
'-/analytics/value_stream_analytics'
)
end
...
...
ee/config/routes/group.rb
View file @
569a4bf4
...
...
@@ -36,6 +36,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end
end
resource
:summary
,
controller: :summary
,
only: :show
get
'/time_summary'
=>
'summary#time_summary'
end
get
'/cycle_analytics'
,
to:
redirect
(
'-/analytics/value_stream_analytics'
)
end
...
...
ee/spec/controllers/analytics/cycle_analytics/summary_controller_spec.rb
View file @
569a4bf4
...
...
@@ -15,9 +15,7 @@ describe Analytics::CycleAnalytics::SummaryController do
sign_in
(
user
)
end
describe
'GET `show`'
do
subject
{
get
:show
,
params:
params
}
shared_examples
'summary endpoint'
do
it
'succeeds'
do
subject
...
...
@@ -46,4 +44,16 @@ describe Analytics::CycleAnalytics::SummaryController do
include_examples
'cycle analytics data endpoint examples'
include_examples
'group permission check on the controller level'
end
describe
'GET "show"'
do
subject
{
get
:show
,
params:
params
}
it_behaves_like
'summary endpoint'
end
describe
'GET "time_summary"'
do
subject
{
get
:time_summary
,
params:
params
}
it_behaves_like
'summary endpoint'
end
end
ee/spec/models/analytics/cycle_analytics/group_level_spec.rb
View file @
569a4bf4
...
...
@@ -12,6 +12,10 @@ describe Analytics::CycleAnalytics::GroupLevel do
let
(
:mr
)
{
create_merge_request_closing_issue
(
user
,
project
,
issue
,
commit_message:
"References
#{
issue
.
to_reference
}
"
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
mr
.
source_branch
,
sha:
mr
.
source_branch_sha
,
head_pipeline_of:
mr
)
}
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
subject
{
described_class
.
new
(
group:
group
,
options:
{
from:
from_date
,
current_user:
user
})
}
describe
'#permissions'
do
...
...
@@ -41,4 +45,22 @@ describe Analytics::CycleAnalytics::GroupLevel do
expect
(
subject
.
summary
.
map
{
|
summary
|
summary
[
:value
]
}).
to
contain_exactly
(
'0.1'
,
'1'
,
'1'
)
end
end
describe
'#time_summary'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
before
do
# lead_time: 1 day, cycle_time: 2 days
issue
.
update!
(
created_at:
5
.
days
.
ago
)
issue
.
metrics
.
update!
(
first_mentioned_in_commit_at:
4
.
days
.
ago
)
issue
.
update!
(
closed_at:
3
.
days
.
ago
)
end
it
'returns medians for lead time and cycle type'
do
expect
(
subject
.
time_summary
.
map
{
|
summary
|
summary
[
:value
]
}).
to
contain_exactly
(
'1.0'
,
'2.0'
)
end
end
end
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