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
Léo-Paul Géneau
gitlab-ce
Commits
d3fef0fb
Commit
d3fef0fb
authored
Aug 25, 2016
by
Timothy Andrew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the "Staging" cycle analytics section.
parent
14d6317e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
2 deletions
+38
-2
app/models/cycle_analytics.rb
app/models/cycle_analytics.rb
+9
-2
app/models/cycle_analytics/queries.rb
app/models/cycle_analytics/queries.rb
+22
-0
app/views/projects/cycle_analytics/show.html.haml
app/views/projects/cycle_analytics/show.html.haml
+7
-0
No files found.
app/models/cycle_analytics.rb
View file @
d3fef0fb
...
...
@@ -15,18 +15,25 @@ class CycleAnalytics
def
code
issues
=
Issue
.
all
.
to_a
start_time_fn
=
->
(
merge_request
)
{
merge_request
.
created_at
}
calculate_metric
(
issues
.
map
{
|
issue
|
issue
.
closed_by_merge_requests
(
nil
,
check_if_open:
false
)
}.
flatten
,
calculate_metric
(
Queries
::
merge_requests_closing_issues
(
issues
)
,
start_time_fn
,
Queries
::
mr_wip_flag_removed_or_assigned_to_user_other_than_author_time
)
end
def
review
issues
=
Issue
.
all
.
to_a
calculate_metric
(
issues
.
map
{
|
issue
|
issue
.
closed_by_merge_requests
(
nil
,
check_if_open:
false
)
}.
flatten
,
calculate_metric
(
Queries
::
merge_requests_closing_issues
(
issues
)
,
Queries
::
mr_wip_flag_removed_or_assigned_to_user_other_than_author_time
,
Queries
::
mr_first_closed_or_merged_at
)
end
def
staging
issues
=
Issue
.
all
.
to_a
calculate_metric
(
Queries
::
merge_requests_closing_issues
(
issues
),
Queries
::
mr_merged_at
,
Queries
::
mr_deployed_to_any_environment_at
)
end
private
def
calculate_metric
(
data
,
start_time_fn
,
end_time_fn
)
...
...
app/models/cycle_analytics/queries.rb
View file @
d3fef0fb
class
CycleAnalytics
module
Queries
class
<<
self
def
merge_requests_closing_issues
(
issues
)
issues
.
map
{
|
issue
|
issue
.
closed_by_merge_requests
(
nil
,
check_if_open:
false
)
}.
flatten
end
def
issue_first_associated_with_milestone_or_first_added_to_list_label_time
lambda
do
|
issue
|
if
issue
.
metrics
.
present?
...
...
@@ -18,6 +22,24 @@ class CycleAnalytics
end
end
def
mr_merged_at
lambda
do
|
merge_request
|
if
merge_request
.
metrics
.
present?
merge_request
.
metrics
.
merged_at
end
end
end
def
mr_deployed_to_any_environment_at
lambda
do
|
merge_request
|
if
merge_request
.
metrics
.
present?
deployments
=
Deployment
.
where
(
ref:
merge_request
.
target_branch
).
where
(
"created_at > ?"
,
merge_request
.
metrics
.
merged_at
)
deployment
=
deployments
.
order
(
:created_at
).
first
deployment
.
created_at
if
deployment
end
end
end
def
issue_closing_merge_request_opened_time
lambda
do
|
issue
|
merge_requests
=
issue
.
closed_by_merge_requests
(
nil
,
check_if_open:
false
)
...
...
app/views/projects/cycle_analytics/show.html.haml
View file @
d3fef0fb
...
...
@@ -26,3 +26,10 @@
=
distance_of_time_in_words
review
-
else
=
"<Not enough data>"
%li
.list-group-item
Staging:
-
if
staging
=
@cycle_analytics
.
staging
.
presence
=
distance_of_time_in_words
staging
-
else
=
"<Not enough data>"
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