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
dc6ea14b
Commit
dc6ea14b
authored
Nov 22, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed stage entity and added missing stage specs
parent
a9982762
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
93 additions
and
3 deletions
+93
-3
app/serializers/analytics_stage_entity.rb
app/serializers/analytics_stage_entity.rb
+2
-2
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+5
-1
spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+30
-0
spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
+8
-0
No files found.
app/serializers/analytics_stage_entity.rb
View file @
dc6ea14b
...
@@ -2,11 +2,11 @@ class AnalyticsStageEntity < Grape::Entity
...
@@ -2,11 +2,11 @@ class AnalyticsStageEntity < Grape::Entity
include
EntityDateHelper
include
EntityDateHelper
expose
:stage
,
as: :title
do
|
object
|
expose
:stage
,
as: :title
do
|
object
|
object
[
:stage
]
.
to_s
.
capitalize
object
.
stage
.
to_s
.
capitalize
end
end
expose
:description
expose
:description
expose
:median
,
as: :value
do
|
stage
|
expose
:median
,
as: :value
do
|
stage
|
stage
[
:median
]
&&
!
stage
[
:median
].
zero?
?
distance_of_time_in_words
(
stage
[
:median
]
)
:
nil
stage
.
median
&&
!
stage
.
median
.
zero?
?
distance_of_time_in_words
(
stage
.
median
)
:
nil
end
end
end
end
lib/gitlab/cycle_analytics/base_stage.rb
View file @
dc6ea14b
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
class
BaseStage
class
BaseStage
attr_reader
:stage
,
:description
attr_reader
:stage
,
:description
def
initialize
(
project
:,
options
:,
stage:
stage
)
def
initialize
(
project
:,
options
:,
stage
:)
@project
=
project
@project
=
project
@options
=
options
@options
=
options
@fetcher
=
Gitlab
::
CycleAnalytics
::
MetricsFetcher
.
new
(
project:
project
,
@fetcher
=
Gitlab
::
CycleAnalytics
::
MetricsFetcher
.
new
(
project:
project
,
...
@@ -16,6 +16,10 @@ module Gitlab
...
@@ -16,6 +16,10 @@ module Gitlab
event_class
.
new
(
fetcher:
@fetcher
,
stage:
@stage
).
fetch
event_class
.
new
(
fetcher:
@fetcher
,
stage:
@stage
).
fetch
end
end
def
median_data
AnalyticsStageSerializer
.
new
.
represent
(
self
).
as_json
end
private
private
def
event_class
def
event_class
...
...
spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
CodeStage
do
let
(
:stage_name
)
{
:code
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
IssueStage
do
let
(
:stage_name
)
{
:issue
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
PlanStage
do
let
(
:stage_name
)
{
:plan
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
ProductionStage
do
let
(
:stage_name
)
{
:production
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
ReviewStage
do
let
(
:stage_name
)
{
:review
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
shared_examples
'base stage'
do
let
(
:stage
)
{
described_class
.
new
(
project:
double
,
options:
{},
stage:
stage_name
)
}
before
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
MetricsFetcher
).
to
receive
(
:calculate_metric
).
and_return
(
1.12
)
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
BaseEvent
).
to
receive
(
:event_result
).
and_return
({})
end
it
'has the median data value'
do
expect
(
stage
.
median_data
[
:value
]).
not_to
be_nil
end
it
'has the median data stage'
do
expect
(
stage
.
median_data
[
:title
]).
not_to
be_nil
end
it
'has the median data description'
do
expect
(
stage
.
median_data
[
:description
]).
not_to
be_nil
end
it
'has the stage'
do
expect
(
stage
.
stage
).
to
eq
(
stage_name
)
end
it
'has the events'
do
expect
(
stage
.
events
).
not_to
be_nil
end
end
spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
StagingStage
do
let
(
:stage_name
)
{
:staging
}
it_behaves_like
'base stage'
end
spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
0 → 100644
View file @
dc6ea14b
require
'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_stage_spec'
describe
Gitlab
::
CycleAnalytics
::
TestStage
do
let
(
:stage_name
)
{
:test
}
it_behaves_like
'base stage'
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