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
a67311cb
Commit
a67311cb
authored
Nov 23, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix other spec failures
parent
02e1e481
Changes
20
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
128 additions
and
131 deletions
+128
-131
app/controllers/concerns/cycle_analytics_params.rb
app/controllers/concerns/cycle_analytics_params.rb
+2
-2
app/controllers/projects/cycle_analytics/events_controller.rb
...controllers/projects/cycle_analytics/events_controller.rb
+13
-13
app/controllers/projects/cycle_analytics_controller.rb
app/controllers/projects/cycle_analytics_controller.rb
+2
-2
app/models/cycle_analytics.rb
app/models/cycle_analytics.rb
+7
-4
lib/gitlab/cycle_analytics/base_event.rb
lib/gitlab/cycle_analytics/base_event.rb
+2
-1
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+1
-1
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+0
-38
lib/gitlab/cycle_analytics/stage_summary.rb
lib/gitlab/cycle_analytics/stage_summary.rb
+1
-3
lib/gitlab/cycle_analytics/summary/base.rb
lib/gitlab/cycle_analytics/summary/base.rb
+1
-1
spec/lib/gitlab/cycle_analytics/code_event_spec.rb
spec/lib/gitlab/cycle_analytics/code_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+75
-62
spec/lib/gitlab/cycle_analytics/issue_event_spec.rb
spec/lib/gitlab/cycle_analytics/issue_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/plan_event_spec.rb
spec/lib/gitlab/cycle_analytics/plan_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/production_event_spec.rb
spec/lib/gitlab/cycle_analytics/production_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/review_event_spec.rb
spec/lib/gitlab/cycle_analytics/review_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
+7
-1
spec/lib/gitlab/cycle_analytics/staging_event_spec.rb
spec/lib/gitlab/cycle_analytics/staging_event_spec.rb
+2
-0
spec/lib/gitlab/cycle_analytics/test_event_spec.rb
spec/lib/gitlab/cycle_analytics/test_event_spec.rb
+2
-0
spec/models/cycle_analytics/summary_spec.rb
spec/models/cycle_analytics/summary_spec.rb
+1
-1
spec/serializers/analytics_summary_serializer_spec.rb
spec/serializers/analytics_summary_serializer_spec.rb
+2
-2
No files found.
app/controllers/concerns/cycle_analytics_params.rb
View file @
a67311cb
module
CycleAnalyticsParams
extend
ActiveSupport
::
Concern
def
options
@options
||=
{
from:
start_date
(
events_
params
),
current_user:
current_user
}
def
options
(
params
)
@options
||=
{
from:
start_date
(
params
),
current_user:
current_user
}
end
def
start_date
(
params
)
...
...
app/controllers/projects/cycle_analytics/events_controller.rb
View file @
a67311cb
...
...
@@ -9,46 +9,46 @@ module Projects
before_action
:authorize_read_merge_request!
,
only:
[
:code
,
:review
]
def
issue
render_events
(
events
.
issue_events
)
render_events
(
cycle_analytics
.
events_for
(
:issue
)
)
end
def
plan
render_events
(
events
.
plan_events
)
render_events
(
cycle_analytics
.
events_for
(
:plan
)
)
end
def
code
render_events
(
events
.
code_events
)
render_events
(
cycle_analytics
.
events_for
(
:code
)
)
end
def
test
options
[
:branch
]
=
events_params
[
:branch_name
]
options
(
events_params
)
[
:branch
]
=
events_params
[
:branch_name
]
render_events
(
events
.
test_events
)
render_events
(
cycle_analytics
.
events_for
(
:test
)
)
end
def
review
render_events
(
events
.
review_events
)
render_events
(
cycle_analytics
.
events_for
(
:review
)
)
end
def
staging
render_events
(
events
.
staging_events
)
render_events
(
cycle_analytics
.
events_for
(
:staging
)
)
end
def
production
render_events
(
events
.
production_events
)
render_events
(
cycle_analytics
.
events_for
(
:production
)
)
end
private
def
render_events
(
events
_list
)
def
render_events
(
events
)
respond_to
do
|
format
|
format
.
html
format
.
json
{
render
json:
{
events:
events
_list
}
}
format
.
json
{
render
json:
{
events:
events
}
}
end
end
def
event
s
@
events
||=
Gitlab
::
CycleAnalytics
::
Events
.
new
(
project:
project
,
options:
options
)
def
cycle_analytic
s
@
cycle_analytics
||=
::
CycleAnalytics
.
new
(
project
,
options:
options
(
events_params
)
)
end
def
events_params
...
...
app/controllers/projects/cycle_analytics_controller.rb
View file @
a67311cb
...
...
@@ -6,7 +6,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
before_action
:authorize_read_cycle_analytics!
def
show
@cycle_analytics
=
::
CycleAnalytics
.
new
(
@project
,
options:
options
)
@cycle_analytics
=
::
CycleAnalytics
.
new
(
@project
,
options:
options
(
cycle_analytics_params
)
)
@cycle_analytics_no_data
=
@cycle_analytics
.
no_stats?
...
...
@@ -21,7 +21,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
def
cycle_analytics_params
return
{}
unless
params
[
:cycle_analytics
].
present?
{
start_date:
params
[
:cycle_analytics
][
:start_date
]
}
params
[
:cycle_analytics
].
slice
(
:start_date
)
end
def
cycle_analytics_json
...
...
app/models/cycle_analytics.rb
View file @
a67311cb
...
...
@@ -7,7 +7,7 @@ class CycleAnalytics
end
def
summary
@summary
||=
Gitlab
::
CycleAnalytics
::
Summary
.
new
(
@project
,
from:
@options
[
:from
]).
data
@summary
||=
::
Gitlab
::
CycleAnalytics
::
Stage
Summary
.
new
(
@project
,
from:
@options
[
:from
]).
data
end
def
stats
...
...
@@ -15,23 +15,26 @@ class CycleAnalytics
end
def
no_stats?
stats
.
map
(
&
:value
)
.
compact
.
empty?
stats
.
map
{
|
hash
|
hash
[
:value
]
}
.
compact
.
empty?
end
def
permissions
(
user
:)
Gitlab
::
CycleAnalytics
::
Permissions
.
get
(
user:
user
,
project:
@project
)
end
def
events_for
(
stage
)
classify_stage
(
stage
).
new
(
project:
@project
,
options:
@options
,
stage:
stage
).
events
end
private
def
stats_per_stage
STAGES
.
map
do
|
stage_name
|
classify_stage
(
method_sym
).
new
(
project:
@project
,
options:
@options
,
stage:
stage_name
).
median_data
classify_stage
(
stage_name
).
new
(
project:
@project
,
options:
@options
,
stage:
stage_name
).
median_data
end
end
def
classify_stage
(
stage_name
)
"Gitlab::CycleAnalytics::
#{
stage_name
.
to_s
.
capitalize
}
Stage"
.
constantize
end
end
lib/gitlab/cycle_analytics/base_event.rb
View file @
a67311cb
...
...
@@ -5,10 +5,11 @@ module Gitlab
attr_reader
:stage
,
:start_time_attrs
,
:end_time_attrs
,
:projections
,
:query
def
initialize
(
fetcher
:,
stage
:)
def
initialize
(
fetcher
:,
stage
:
,
options
:
)
@query
=
EventsQuery
.
new
(
fetcher:
fetcher
)
@project
=
fetcher
.
project
@stage
=
stage
@options
=
options
end
def
fetch
...
...
lib/gitlab/cycle_analytics/base_stage.rb
View file @
a67311cb
...
...
@@ -13,7 +13,7 @@ module Gitlab
end
def
events
event_class
.
new
(
fetcher:
@fetcher
,
stage:
@stage
).
fetch
event_class
.
new
(
fetcher:
@fetcher
,
stage:
@stage
,
options:
@options
).
fetch
end
def
median_data
...
...
lib/gitlab/cycle_analytics/events.rb
deleted
100644 → 0
View file @
02e1e481
module
Gitlab
module
CycleAnalytics
class
Events
def
initialize
(
project
:,
options
:)
@project
=
project
@options
=
options
end
def
issue_events
IssueEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
plan_events
PlanEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
code_events
CodeEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
test_events
TestEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
review_events
ReviewEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
staging_events
StagingEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
def
production_events
ProductionEvent
.
new
(
project:
@project
,
options:
@options
).
fetch
end
end
end
end
lib/gitlab/cycle_analytics/summary.rb
→
lib/gitlab/cycle_analytics/s
tage_s
ummary.rb
View file @
a67311cb
module
Gitlab
module
CycleAnalytics
module
Summary
extend
self
class
StageSummary
def
initialize
(
project
,
from
:)
@project
=
project
@from
=
from
...
...
lib/gitlab/cycle_analytics/summary/base.rb
View file @
a67311cb
...
...
@@ -8,7 +8,7 @@ module Gitlab
end
def
title
self
.
nam
e
self
.
class
.
name
.
demoduliz
e
end
def
value
...
...
spec/lib/gitlab/cycle_analytics/code_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
CodeEvent
do
let
(
:stage_name
)
{
:code
}
it_behaves_like
'default query config'
do
it
'does not have the default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
a67311cb
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/cycle_analytics/issue_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
IssueEvent
do
let
(
:stage_name
)
{
:issue
}
it_behaves_like
'default query config'
do
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/plan_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
PlanEvent
do
let
(
:stage_name
)
{
:plan
}
it_behaves_like
'default query config'
do
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/production_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
ProductionEvent
do
let
(
:stage_name
)
{
:production
}
it_behaves_like
'default query config'
do
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/review_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
ReviewEvent
do
let
(
:stage_name
)
{
:review
}
it_behaves_like
'default query config'
do
it
'has the default order'
do
expect
(
event
.
order
).
to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
View file @
a67311cb
require
'spec_helper'
shared_examples
'default query config'
do
let
(
:event
)
{
described_class
.
new
(
project:
double
,
options:
{})
}
let
(
:fetcher
)
do
Gitlab
::
CycleAnalytics
::
MetricsFetcher
.
new
(
project:
create
(
:empty_project
),
from:
1
.
day
.
ago
,
branch:
nil
)
end
let
(
:event
)
{
described_class
.
new
(
fetcher:
fetcher
,
stage:
stage_name
,
options:
{})
}
it
'has the start attributes'
do
expect
(
event
.
start_time_attrs
).
not_to
be_nil
...
...
spec/lib/gitlab/cycle_analytics/staging_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
StagingEvent
do
let
(
:stage_name
)
{
:staging
}
it_behaves_like
'default query config'
do
it
'does not have the default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
...
...
spec/lib/gitlab/cycle_analytics/test_event_spec.rb
View file @
a67311cb
...
...
@@ -2,6 +2,8 @@ require 'spec_helper'
require
'lib/gitlab/cycle_analytics/shared_event_spec'
describe
Gitlab
::
CycleAnalytics
::
TestEvent
do
let
(
:stage_name
)
{
:test
}
it_behaves_like
'default query config'
do
it
'does not have the default order'
do
expect
(
event
.
order
).
not_to
eq
(
event
.
start_time_attrs
)
...
...
spec/models/cycle_analytics/summary_spec.rb
View file @
a67311cb
require
'spec_helper'
describe
CycleAnalytics
::
Summary
,
models:
true
do
describe
Gitlab
::
CycleAnalytics
::
Stage
Summary
,
models:
true
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:from
)
{
Time
.
now
}
let
(
:user
)
{
create
(
:user
,
:admin
)
}
...
...
spec/serializers/analytics_summary_serializer_spec.rb
View file @
a67311cb
...
...
@@ -8,10 +8,10 @@ describe AnalyticsSummarySerializer do
let
(
:json
)
{
serializer
.
as_json
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:resource
)
{
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
.
new
(
project:
double
,
from:
1
.
day
.
ago
)
}
let
(
:resource
)
{
Gitlab
::
CycleAnalytics
::
S
tageS
ummary
::
Issue
.
new
(
project:
double
,
from:
1
.
day
.
ago
)
}
before
do
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
Summary
::
Issue
).
to
receive
(
:value
).
and_return
(
1.12
)
allow_any_instance_of
(
Gitlab
::
CycleAnalytics
::
S
tageS
ummary
::
Issue
).
to
receive
(
:value
).
and_return
(
1.12
)
end
it
'it generates payload for single object'
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