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
Tatuya Kamada
gitlab-ce
Commits
150a4485
Commit
150a4485
authored
Jan 12, 2017
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored a bunch of stuff based on feedback
parent
34875ce6
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
54 additions
and
48 deletions
+54
-48
app/models/cycle_analytics.rb
app/models/cycle_analytics.rb
+2
-2
lib/gitlab/cycle_analytics/base_event_fetcher.rb
lib/gitlab/cycle_analytics/base_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+10
-10
lib/gitlab/cycle_analytics/code_stage.rb
lib/gitlab/cycle_analytics/code_stage.rb
+5
-4
lib/gitlab/cycle_analytics/event_fetcher.rb
lib/gitlab/cycle_analytics/event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/issue_stage.rb
lib/gitlab/cycle_analytics/issue_stage.rb
+6
-5
lib/gitlab/cycle_analytics/plan_stage.rb
lib/gitlab/cycle_analytics/plan_stage.rb
+6
-5
lib/gitlab/cycle_analytics/production_stage.rb
lib/gitlab/cycle_analytics/production_stage.rb
+5
-4
lib/gitlab/cycle_analytics/review_stage.rb
lib/gitlab/cycle_analytics/review_stage.rb
+5
-4
lib/gitlab/cycle_analytics/staging_stage.rb
lib/gitlab/cycle_analytics/staging_stage.rb
+5
-5
lib/gitlab/cycle_analytics/test_stage.rb
lib/gitlab/cycle_analytics/test_stage.rb
+5
-4
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+3
-3
No files found.
app/models/cycle_analytics.rb
View file @
150a4485
...
...
@@ -17,7 +17,7 @@ class CycleAnalytics
end
def
no_stats?
stats
.
map
{
|
hash
|
hash
[
:value
]
}.
compact
.
empty?
stats
.
all?
{
hash
[
:value
].
nil?
}
end
def
permissions
(
user
:)
...
...
@@ -32,7 +32,7 @@ class CycleAnalytics
def
stats_per_stage
STAGES
.
map
do
|
stage_name
|
self
[
stage_name
].
median_data
self
[
stage_name
].
as_json
end
end
end
lib/gitlab/cycle_analytics/base_event_fetcher.rb
View file @
150a4485
...
...
@@ -42,7 +42,7 @@ module Gitlab
end
def
default_order
@options
[
:start_time_attrs
].
is_a?
(
Array
)
?
@options
[
:start_time_attrs
].
first
:
@options
[
:start_time_attrs
]
[
@options
[
:start_time_attrs
]].
flatten
.
first
end
def
serialize
(
_event
)
...
...
lib/gitlab/cycle_analytics/base_stage.rb
View file @
150a4485
...
...
@@ -8,17 +8,11 @@ module Gitlab
@options
=
options
end
def
event
@event
||=
Gitlab
::
CycleAnalytics
::
Event
[
name
].
new
(
project:
@project
,
stage:
name
,
options:
event_options
)
end
def
events
event
.
fetch
event
_fetcher
.
fetch
end
def
median_data
def
as_json
AnalyticsStageSerializer
.
new
.
represent
(
self
).
as_json
end
...
...
@@ -35,7 +29,7 @@ module Gitlab
# cycle analytics stage.
interval_query
=
Arel
::
Nodes
::
As
.
new
(
cte_table
,
subtract_datetimes
(
base_query
.
dup
,
@start_time_attrs
,
@
end_time_attrs
,
name
.
to_s
))
subtract_datetimes
(
base_query
.
dup
,
start_time_attrs
,
end_time_attrs
,
name
.
to_s
))
median_datetime
(
cte_table
,
interval_query
,
name
)
end
...
...
@@ -46,8 +40,14 @@ module Gitlab
private
def
event_fetcher
@event_fetcher
||=
Gitlab
::
CycleAnalytics
::
EventFetcher
[
name
].
new
(
project:
@project
,
stage:
name
,
options:
event_options
)
end
def
event_options
@options
.
merge
(
start_time_attrs:
@start_time_attrs
,
end_time_attrs:
@
end_time_attrs
)
@options
.
merge
(
start_time_attrs:
start_time_attrs
,
end_time_attrs:
end_time_attrs
)
end
end
end
...
...
lib/gitlab/cycle_analytics/code_stage.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
class
CodeStage
<
BaseStage
def
initialize
(
*
args
)
@start_time_attrs
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
@end_time_attrs
=
mr_table
[
:created_at
]
def
start_time_attrs
@start_time_attrs
||
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_table
[
:created_at
]
end
def
name
...
...
lib/gitlab/cycle_analytics/event.rb
→
lib/gitlab/cycle_analytics/event
_fetcher
.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
module
Event
module
Event
Fetcher
def
self
.
[]
(
stage_name
)
CycleAnalytics
.
const_get
(
"
#{
stage_name
.
to_s
.
camelize
}
EventFetcher"
)
end
...
...
lib/gitlab/cycle_analytics/issue_stage.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
class
IssueStage
<
BaseStage
def
initialize
(
*
args
)
@start_time_attrs
=
issue_table
[
:created_at
]
@end_time_attrs
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
def
start_time_attrs
@start_time_attrs
||=
issue_table
[
:created_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
end
def
name
...
...
lib/gitlab/cycle_analytics/plan_stage.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
class
PlanStage
<
BaseStage
def
initialize
(
*
args
)
@start_time_attrs
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
@end_time_attrs
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
def
start_time_attrs
@start_time_attrs
||
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
end
def
name
...
...
lib/gitlab/cycle_analytics/production_stage.rb
View file @
150a4485
...
...
@@ -3,11 +3,12 @@ module Gitlab
class
ProductionStage
<
BaseStage
include
ProductionHelper
def
initialize
(
*
args
)
@start_time_attrs
=
issue_table
[
:created_at
]
@end_time_attrs
=
mr_metrics_table
[
:first_deployed_to_production_at
]
def
start_time_attrs
@start_time_attrs
||
=
issue_table
[
:created_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:first_deployed_to_production_at
]
end
def
name
...
...
lib/gitlab/cycle_analytics/review_stage.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
class
ReviewStage
<
BaseStage
def
initialize
(
*
args
)
@start_time_attrs
=
mr_table
[
:created_at
]
@end_time_attrs
=
mr_metrics_table
[
:merged_at
]
def
start_time_attrs
@start_time_attrs
||
=
mr_table
[
:created_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:merged_at
]
end
def
name
...
...
lib/gitlab/cycle_analytics/staging_stage.rb
View file @
150a4485
...
...
@@ -2,12 +2,12 @@ module Gitlab
module
CycleAnalytics
class
StagingStage
<
BaseStage
include
ProductionHelper
def
start_time_attrs
@start_time_attrs
||=
mr_metrics_table
[
:merged_at
]
end
def
initialize
(
*
args
)
@start_time_attrs
=
mr_metrics_table
[
:merged_at
]
@end_time_attrs
=
mr_metrics_table
[
:first_deployed_to_production_at
]
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:first_deployed_to_production_at
]
end
def
name
...
...
lib/gitlab/cycle_analytics/test_stage.rb
View file @
150a4485
module
Gitlab
module
CycleAnalytics
class
TestStage
<
BaseStage
def
initialize
(
*
args
)
@start_time_attrs
=
mr_metrics_table
[
:latest_build_started_at
]
@end_time_attrs
=
mr_metrics_table
[
:latest_build_finished_at
]
def
start_time_attrs
@start_time_attrs
||=
mr_metrics_table
[
:latest_build_started_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:latest_build_finished_at
]
end
def
name
...
...
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
View file @
150a4485
...
...
@@ -9,15 +9,15 @@ shared_examples 'base stage' do
end
it
'has the median data value'
do
expect
(
stage
.
median_data
[
:value
]).
not_to
be_nil
expect
(
stage
.
as_json
[
:value
]).
not_to
be_nil
end
it
'has the median data stage'
do
expect
(
stage
.
median_data
[
:title
]).
not_to
be_nil
expect
(
stage
.
as_json
[
:title
]).
not_to
be_nil
end
it
'has the median data description'
do
expect
(
stage
.
median_data
[
:description
]).
not_to
be_nil
expect
(
stage
.
as_json
[
:description
]).
not_to
be_nil
end
it
'has the title'
do
...
...
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