BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
a4a0ce95
Commit
a4a0ce95
authored
Sep 20, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move JSON generation (cycle analytics) into a controller method.
Helper methods are meant for views
parent
c9247c05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
37 deletions
+34
-37
cycle_analytics_controller.rb
app/controllers/projects/cycle_analytics_controller.rb
+34
-2
cycle_analytics_helper.rb
app/helpers/cycle_analytics_helper.rb
+0
-35
No files found.
app/controllers/projects/cycle_analytics_controller.rb
View file @
a4a0ce95
class
Projects
::
CycleAnalyticsController
<
Projects
::
ApplicationController
include
CycleAnalytics
Helper
include
ActionView
::
Helpers
::
Date
Helper
before_action
:authorize_read_cycle_analytics!
...
...
@@ -8,7 +8,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
cycle_analytics_json
(
@cycle_analytics
)
}
format
.
json
{
render
json:
cycle_analytics_json
}
end
end
...
...
@@ -27,4 +27,36 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
{
start_date:
params
[
:cycle_analytics
][
:start_date
]
}
end
def
cycle_analytics_json
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"
],
[
:test
,
"Test"
,
"Total test time for all commits/merges"
],
[
:review
,
"Review"
,
"Time between merge request creation and merge/close"
],
[
:staging
,
"Staging"
,
"From merge request merge until deploy to production"
],
[
:production
,
"Production"
,
"From issue creation until deploy to production"
]]
stats
=
cycle_analytics_view_data
.
reduce
([])
do
|
stats
,
(
stage_method
,
stage_text
,
stage_description
)
|
value
=
@cycle_analytics
.
send
(
stage_method
).
presence
stats
<<
{
title:
stage_text
,
description:
stage_description
,
value:
value
&&
!
value
.
zero?
?
distance_of_time_in_words
(
value
)
:
nil
}
stats
end
summary
=
[
{
title:
"New Issues"
,
value:
@cycle_analytics
.
summary
.
new_issues
},
{
title:
"Commits"
,
value:
@cycle_analytics
.
summary
.
commits
},
{
title:
"Deploys"
,
value:
@cycle_analytics
.
summary
.
deploys
}
]
{
summary:
summary
,
stats:
stats
}
end
end
app/helpers/cycle_analytics_helper.rb
deleted
100644 → 0
View file @
c9247c05
module
CycleAnalyticsHelper
include
ActionView
::
Helpers
::
DateHelper
def
cycle_analytics_json
(
cycle_analytics
)
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"
],
[
:test
,
"Test"
,
"Total test time for all commits/merges"
],
[
:review
,
"Review"
,
"Time between merge request creation and merge/close"
],
[
:staging
,
"Staging"
,
"From merge request merge until deploy to production"
],
[
:production
,
"Production"
,
"From issue creation until deploy to production"
]]
stats
=
cycle_analytics_view_data
.
reduce
([])
do
|
stats
,
(
stage_method
,
stage_text
,
stage_description
)
|
value
=
cycle_analytics
.
send
(
stage_method
).
presence
stats
<<
{
title:
stage_text
,
description:
stage_description
,
value:
value
&&
!
value
.
zero?
?
distance_of_time_in_words
(
value
)
:
nil
}
stats
end
summary
=
[
{
title:
"New Issues"
,
value:
cycle_analytics
.
summary
.
new_issues
},
{
title:
"Commits"
,
value:
cycle_analytics
.
summary
.
commits
},
{
title:
"Deploys"
,
value:
cycle_analytics
.
summary
.
deploys
}
]
{
summary:
summary
,
stats:
stats
}
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