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
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
...
@@ -17,7 +17,7 @@ class CycleAnalytics
end
end
def
no_stats?
def
no_stats?
stats
.
map
{
|
hash
|
hash
[
:value
]
}.
compact
.
empty?
stats
.
all?
{
hash
[
:value
].
nil?
}
end
end
def
permissions
(
user
:)
def
permissions
(
user
:)
...
@@ -32,7 +32,7 @@ class CycleAnalytics
...
@@ -32,7 +32,7 @@ class CycleAnalytics
def
stats_per_stage
def
stats_per_stage
STAGES
.
map
do
|
stage_name
|
STAGES
.
map
do
|
stage_name
|
self
[
stage_name
].
median_data
self
[
stage_name
].
as_json
end
end
end
end
end
end
lib/gitlab/cycle_analytics/base_event_fetcher.rb
View file @
150a4485
...
@@ -42,7 +42,7 @@ module Gitlab
...
@@ -42,7 +42,7 @@ module Gitlab
end
end
def
default_order
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
end
def
serialize
(
_event
)
def
serialize
(
_event
)
...
...
lib/gitlab/cycle_analytics/base_stage.rb
View file @
150a4485
...
@@ -8,17 +8,11 @@ module Gitlab
...
@@ -8,17 +8,11 @@ module Gitlab
@options
=
options
@options
=
options
end
end
def
event
@event
||=
Gitlab
::
CycleAnalytics
::
Event
[
name
].
new
(
project:
@project
,
stage:
name
,
options:
event_options
)
end
def
events
def
events
event
.
fetch
event
_fetcher
.
fetch
end
end
def
median_data
def
as_json
AnalyticsStageSerializer
.
new
.
represent
(
self
).
as_json
AnalyticsStageSerializer
.
new
.
represent
(
self
).
as_json
end
end
...
@@ -35,7 +29,7 @@ module Gitlab
...
@@ -35,7 +29,7 @@ module Gitlab
# cycle analytics stage.
# cycle analytics stage.
interval_query
=
Arel
::
Nodes
::
As
.
new
(
interval_query
=
Arel
::
Nodes
::
As
.
new
(
cte_table
,
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
)
median_datetime
(
cte_table
,
interval_query
,
name
)
end
end
...
@@ -46,8 +40,14 @@ module Gitlab
...
@@ -46,8 +40,14 @@ module Gitlab
private
private
def
event_fetcher
@event_fetcher
||=
Gitlab
::
CycleAnalytics
::
EventFetcher
[
name
].
new
(
project:
@project
,
stage:
name
,
options:
event_options
)
end
def
event_options
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
end
end
end
...
...
lib/gitlab/cycle_analytics/code_stage.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
CodeStage
<
BaseStage
class
CodeStage
<
BaseStage
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
@start_time_attrs
||
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
@end_time_attrs
=
mr_table
[
:created_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_table
[
:created_at
]
end
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/event.rb
→
lib/gitlab/cycle_analytics/event
_fetcher
.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
module
Event
module
Event
Fetcher
def
self
.
[]
(
stage_name
)
def
self
.
[]
(
stage_name
)
CycleAnalytics
.
const_get
(
"
#{
stage_name
.
to_s
.
camelize
}
EventFetcher"
)
CycleAnalytics
.
const_get
(
"
#{
stage_name
.
to_s
.
camelize
}
EventFetcher"
)
end
end
...
...
lib/gitlab/cycle_analytics/issue_stage.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
IssueStage
<
BaseStage
class
IssueStage
<
BaseStage
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
issue_table
[
:created_at
]
@start_time_attrs
||=
issue_table
[
:created_at
]
@end_time_attrs
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
end
issue_metrics_table
[
:first_added_to_board_at
]]
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
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/plan_stage.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
PlanStage
<
BaseStage
class
PlanStage
<
BaseStage
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
@start_time_attrs
||
=
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
issue_metrics_table
[
:first_added_to_board_at
]]
@end_time_attrs
=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
issue_metrics_table
[
:first_mentioned_in_commit_at
]
end
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/production_stage.rb
View file @
150a4485
...
@@ -3,11 +3,12 @@ module Gitlab
...
@@ -3,11 +3,12 @@ module Gitlab
class
ProductionStage
<
BaseStage
class
ProductionStage
<
BaseStage
include
ProductionHelper
include
ProductionHelper
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
issue_table
[
:created_at
]
@start_time_attrs
||
=
issue_table
[
:created_at
]
@end_time_attrs
=
mr_metrics_table
[
:first_deployed_to_production_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:first_deployed_to_production_at
]
end
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/review_stage.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
ReviewStage
<
BaseStage
class
ReviewStage
<
BaseStage
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
mr_table
[
:created_at
]
@start_time_attrs
||
=
mr_table
[
:created_at
]
@end_time_attrs
=
mr_metrics_table
[
:merged_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:merged_at
]
end
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/staging_stage.rb
View file @
150a4485
...
@@ -2,12 +2,12 @@ module Gitlab
...
@@ -2,12 +2,12 @@ module Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
StagingStage
<
BaseStage
class
StagingStage
<
BaseStage
include
ProductionHelper
include
ProductionHelper
def
start_time_attrs
@start_time_attrs
||=
mr_metrics_table
[
:merged_at
]
end
def
initialize
(
*
args
)
def
end_time_attrs
@start_time_attrs
=
mr_metrics_table
[
:merged_at
]
@end_time_attrs
||=
mr_metrics_table
[
:first_deployed_to_production_at
]
@end_time_attrs
=
mr_metrics_table
[
:first_deployed_to_production_at
]
super
(
*
args
)
end
end
def
name
def
name
...
...
lib/gitlab/cycle_analytics/test_stage.rb
View file @
150a4485
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
TestStage
<
BaseStage
class
TestStage
<
BaseStage
def
initialize
(
*
args
)
def
start_time_attrs
@start_time_attrs
=
mr_metrics_table
[
:latest_build_started_at
]
@start_time_attrs
||=
mr_metrics_table
[
:latest_build_started_at
]
@end_time_attrs
=
mr_metrics_table
[
:latest_build_finished_at
]
end
super
(
*
args
)
def
end_time_attrs
@end_time_attrs
||=
mr_metrics_table
[
:latest_build_finished_at
]
end
end
def
name
def
name
...
...
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
View file @
150a4485
...
@@ -9,15 +9,15 @@ shared_examples 'base stage' do
...
@@ -9,15 +9,15 @@ shared_examples 'base stage' do
end
end
it
'has the median data value'
do
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
end
it
'has the median data stage'
do
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
end
it
'has the median data description'
do
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
end
it
'has the title'
do
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