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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
dde8fba5
Commit
dde8fba5
authored
Nov 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds a flag to reflect whether or not there is data in cycle analytics
parent
80eaed16
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
5 deletions
+62
-5
app/controllers/projects/cycle_analytics_controller.rb
app/controllers/projects/cycle_analytics_controller.rb
+19
-5
spec/controllers/projects/cycle_analytics_controller_spec.rb
spec/controllers/projects/cycle_analytics_controller_spec.rb
+43
-0
No files found.
app/controllers/projects/cycle_analytics_controller.rb
View file @
dde8fba5
...
...
@@ -8,6 +8,10 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
def
show
@cycle_analytics
=
::
CycleAnalytics
.
new
(
@project
,
from:
start_date
(
cycle_analytics_params
))
stats_values
,
cycle_analytics_json
=
generate_cycle_analytics_json
@cycle_analytics_not_set_up
=
stats_with_no_data?
(
stats_values
)
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
cycle_analytics_json
}
...
...
@@ -22,7 +26,9 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
{
start_date:
params
[
:cycle_analytics
][
:start_date
]
}
end
def
cycle_analytics_json
def
generate_cycle_analytics_json
stats_values
=
[]
cycle_analytics_view_data
=
[[
:issue
,
"Issue"
,
"Time before an issue gets scheduled"
],
[
:plan
,
"Plan"
,
"Time before an issue starts implementation"
],
[
:code
,
"Code"
,
"Time until first merge request"
],
...
...
@@ -34,11 +40,14 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
stats
=
cycle_analytics_view_data
.
reduce
([])
do
|
stats
,
(
stage_method
,
stage_text
,
stage_description
)
|
value
=
@cycle_analytics
.
send
(
stage_method
).
presence
stats_values
<<
value
.
abs
if
value
stats
<<
{
title:
stage_text
,
description:
stage_description
,
value:
value
&&
!
value
.
zero?
?
distance_of_time_in_words
(
value
)
:
nil
}
stats
end
...
...
@@ -52,10 +61,15 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
{
title:
"Deploy"
.
pluralize
(
deploys
),
value:
deploys
}
]
{
summary:
summary
,
cycle_analytics_hash
=
{
summary:
summary
,
stats:
stats
,
permissions:
@cycle_analytics
.
permissions
(
user:
current_user
)
}
[
stats_values
,
cycle_analytics_hash
]
end
def
stats_with_no_data?
(
stats_values
)
stats_values
.
blank?
||
stats_values
.
inject
(:
+
).
zero?
end
end
spec/controllers/projects/cycle_analytics_controller_spec.rb
0 → 100644
View file @
dde8fba5
require
'spec_helper'
describe
Projects
::
CycleAnalyticsController
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
sign_in
(
user
)
project
.
team
<<
[
user
,
:master
]
end
describe
'cycle analytics not set up flag'
do
context
'with no data'
do
it
'is true'
do
get
(
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
)
expect
(
response
).
to
be_success
expect
(
assigns
(
:cycle_analytics_not_set_up
)).
to
eq
(
true
)
end
end
context
'with data'
do
before
do
issue
=
create
(
:issue
,
project:
project
,
created_at:
4
.
days
.
ago
)
milestone
=
create
(
:milestone
,
project:
project
,
created_at:
5
.
days
.
ago
)
issue
.
update
(
milestone:
milestone
)
create_merge_request_closing_issue
(
issue
)
end
it
'is false'
do
get
(
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
)
expect
(
response
).
to
be_success
expect
(
assigns
(
:cycle_analytics_not_set_up
)).
to
eq
(
false
)
end
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