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
Jérome Perrin
gitlab-ce
Commits
3f681f4c
Commit
3f681f4c
authored
Dec 05, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix specs, refactor missing bits from events stuff
parent
b214be49
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
29 additions
and
44 deletions
+29
-44
lib/gitlab/cycle_analytics/base_event_fetcher.rb
lib/gitlab/cycle_analytics/base_event_fetcher.rb
+2
-6
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+3
-1
lib/gitlab/cycle_analytics/event.rb
lib/gitlab/cycle_analytics/event.rb
+1
-1
lib/gitlab/cycle_analytics/metrics_fetcher.rb
lib/gitlab/cycle_analytics/metrics_fetcher.rb
+6
-3
spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
+2
-2
spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
+1
-5
spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
+0
-4
spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
...b/gitlab/cycle_analytics/production_event_fetcher_spec.rb
+1
-5
spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
+1
-5
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
+0
-8
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+8
-0
spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
.../lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
+2
-2
spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
+2
-2
No files found.
lib/gitlab/cycle_analytics/base_event_fetcher.rb
View file @
3f681f4c
...
@@ -3,7 +3,7 @@ module Gitlab
...
@@ -3,7 +3,7 @@ module Gitlab
class
BaseEventFetcher
class
BaseEventFetcher
include
MetricsTables
include
MetricsTables
attr_reader
:projections
,
:query
,
:stage
attr_reader
:projections
,
:query
,
:stage
,
:order
def
initialize
(
fetcher
:,
options
:,
stage
:)
def
initialize
(
fetcher
:,
options
:,
stage
:)
@fetcher
=
fetcher
@fetcher
=
fetcher
...
@@ -22,10 +22,6 @@ module Gitlab
...
@@ -22,10 +22,6 @@ module Gitlab
def
custom_query
(
_base_query
);
end
def
custom_query
(
_base_query
);
end
def
order
@order
||
@start_time_attrs
end
private
private
def
update_author!
def
update_author!
...
@@ -35,7 +31,7 @@ module Gitlab
...
@@ -35,7 +31,7 @@ module Gitlab
end
end
def
event_result
def
event_result
@event_result
||=
@fetcher
.
events
(
self
)
.
to_a
@event_result
||=
@fetcher
.
events
.
to_a
end
end
def
serialize
(
_event
)
def
serialize
(
_event
)
...
...
lib/gitlab/cycle_analytics/base_stage.rb
View file @
3f681f4c
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
BaseStage
class
BaseStage
include
MetricsTables
attr_accessor
:start_time_attrs
,
:end_time_attrs
attr_accessor
:start_time_attrs
,
:end_time_attrs
def
initialize
(
project
:,
options
:)
def
initialize
(
project
:,
options
:)
...
@@ -13,7 +15,7 @@ module Gitlab
...
@@ -13,7 +15,7 @@ module Gitlab
end
end
def
event
def
event
@event
||=
Gitlab
::
CycleAnalytics
::
Event
[
stage
].
new
(
fetcher:
@fetcher
,
options:
@options
)
@event
||=
Gitlab
::
CycleAnalytics
::
Event
[
stage
].
new
(
fetcher:
@fetcher
,
options:
@options
,
stage:
stage
)
end
end
def
events
def
events
...
...
lib/gitlab/cycle_analytics/event.rb
View file @
3f681f4c
...
@@ -2,7 +2,7 @@ module Gitlab
...
@@ -2,7 +2,7 @@ module Gitlab
module
CycleAnalytics
module
CycleAnalytics
module
Event
module
Event
def
self
.
[]
(
stage_name
)
def
self
.
[]
(
stage_name
)
CycleAnalytics
.
const_get
(
"
#{
stage_name
.
to_s
.
camelize
}
Event"
)
CycleAnalytics
.
const_get
(
"
#{
stage_name
.
to_s
.
camelize
}
Event
Fetcher
"
)
end
end
end
end
end
end
...
...
lib/gitlab/cycle_analytics/metrics_fetcher.rb
View file @
3f681f4c
...
@@ -38,13 +38,16 @@ module Gitlab
...
@@ -38,13 +38,16 @@ module Gitlab
def
events_query
def
events_query
base_query
=
base_query_for
(
@stage
.
stage
)
base_query
=
base_query_for
(
@stage
.
stage
)
event
=
@stage
.
event
diff_fn
=
subtract_datetimes_diff
(
base_query
,
@stage
.
start_time_attrs
,
@stage
.
end_time_attrs
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
@stage
.
start_time_attrs
,
@stage
.
end_time_attrs
)
event_instance
.
custom_query
(
base_query
)
@stage
.
event
.
custom_query
(
base_query
)
base_query
.
project
(
extract_diff_epoch
(
diff_fn
).
as
(
'total_time'
),
*
event
.
projections
).
order
(
event
.
order
.
desc
)
base_query
.
project
(
extract_diff_epoch
(
diff_fn
).
as
(
'total_time'
),
*
@stage
.
event
.
projections
).
order
(
order
.
desc
)
end
def
order
@stage
.
event
.
order
||
@stage
.
start_time_attrs
.
is_a?
(
Array
)
?
@stage
.
start_time_attrs
.
first
:
@stage
.
start_time_attrs
end
end
# Join table with a row for every <issue,merge_request> pair (where the merge request
# Join table with a row for every <issue,merge_request> pair (where the merge request
...
...
spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::CodeEventFetcher do
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::CodeEventFetcher do
let
(
:stage_name
)
{
:code
}
let
(
:stage_name
)
{
:code
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
do
it
'
does not have the
default order'
do
it
'
has a
default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
expect
(
event
.
order
).
not_to
be_nil
end
end
end
end
end
end
spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
IssueEventFetcher
do
describe
Gitlab
::
CycleAnalytics
::
IssueEventFetcher
do
let
(
:stage_name
)
{
:issue
}
let
(
:stage_name
)
{
:issue
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
end
end
end
end
spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -5,10 +5,6 @@ describe Gitlab::CycleAnalytics::PlanEventFetcher do
...
@@ -5,10 +5,6 @@ describe Gitlab::CycleAnalytics::PlanEventFetcher do
let
(
:stage_name
)
{
:plan
}
let
(
:stage_name
)
{
:plan
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
do
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
end
context
'no commits'
do
context
'no commits'
do
it
'does not blow up if there are no commits'
do
it
'does not blow up if there are no commits'
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
MetricsFetcher
).
to
receive
(
:events
).
and_return
([{}])
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
MetricsFetcher
).
to
receive
(
:events
).
and_return
([{}])
...
...
spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
ProductionEventFetcher
do
describe
Gitlab
::
CycleAnalytics
::
ProductionEventFetcher
do
let
(
:stage_name
)
{
:production
}
let
(
:stage_name
)
{
:production
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
end
end
end
end
spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
...
@@ -4,9 +4,5 @@ require 'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
ReviewEventFetcher
do
describe
Gitlab
::
CycleAnalytics
::
ReviewEventFetcher
do
let
(
:stage_name
)
{
:review
}
let
(
:stage_name
)
{
:review
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
end
end
end
end
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
View file @
3f681f4c
...
@@ -10,18 +10,10 @@ shared_examples 'default query config' do
...
@@ -10,18 +10,10 @@ shared_examples 'default query config' do
let
(
:event
)
{
described_class
.
new
(
fetcher:
fetcher
,
options:
{},
stage:
stage_name
)
}
let
(
:event
)
{
described_class
.
new
(
fetcher:
fetcher
,
options:
{},
stage:
stage_name
)
}
it
'has the start attributes'
do
expect
(
event
.
start_time_attrs
).
not_to
be_nil
end
it
'has the stage attribute'
do
it
'has the stage attribute'
do
expect
(
event
.
stage
).
not_to
be_nil
expect
(
event
.
stage
).
not_to
be_nil
end
end
it
'has the end attributes'
do
expect
(
event
.
end_time_attrs
).
not_to
be_nil
end
it
'has the projection attributes'
do
it
'has the projection attributes'
do
expect
(
event
.
projections
).
not_to
be_nil
expect
(
event
.
projections
).
not_to
be_nil
end
end
...
...
spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
View file @
3f681f4c
...
@@ -8,6 +8,14 @@ shared_examples 'base stage' do
...
@@ -8,6 +8,14 @@ shared_examples 'base stage' do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
BaseEventFetcher
).
to
receive
(
:event_result
).
and_return
({})
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
BaseEventFetcher
).
to
receive
(
:event_result
).
and_return
({})
end
end
it
'has the start attributes'
do
expect
(
stage
.
start_time_attrs
).
not_to
be_nil
end
it
'has the end attributes'
do
expect
(
stage
.
end_time_attrs
).
not_to
be_nil
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
.
median_data
[
:value
]).
not_to
be_nil
end
end
...
...
spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::StagingEventFetcher do
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::StagingEventFetcher do
let
(
:stage_name
)
{
:staging
}
let
(
:stage_name
)
{
:staging
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
do
it
'
does not have the
default order'
do
it
'
has a
default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
expect
(
event
.
order
).
not_to
be_nil
end
end
end
end
end
end
spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
View file @
3f681f4c
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::TestEventFetcher do
...
@@ -5,8 +5,8 @@ describe Gitlab::CycleAnalytics::TestEventFetcher do
let
(
:stage_name
)
{
:test
}
let
(
:stage_name
)
{
:test
}
it_behaves_like
'default query config'
do
it_behaves_like
'default query config'
do
it
'
does not have the
default order'
do
it
'
has a
default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
expect
(
event
.
order
).
not_to
be_nil
end
end
end
end
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