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
8743e59f
Commit
8743e59f
authored
Nov 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get all stages to use serlalizers - apart from plan - WIP
parent
f5600997
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
28 deletions
+46
-28
app/serializers/analytics_build_entity.rb
app/serializers/analytics_build_entity.rb
+9
-2
app/serializers/analytics_generic_entity.rb
app/serializers/analytics_generic_entity.rb
+2
-6
app/serializers/entity_date_helper.rb
app/serializers/entity_date_helper.rb
+7
-0
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+2
-2
lib/gitlab/cycle_analytics/query_config.rb
lib/gitlab/cycle_analytics/query_config.rb
+1
-1
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+25
-17
No files found.
app/serializers/analytics_build_entity.rb
View file @
8743e59f
class
AnalyticsBuildEntity
<
Grape
::
Entity
class
AnalyticsBuildEntity
<
Grape
::
Entity
include
RequestAwareEntity
include
RequestAwareEntity
include
EntityDateHelper
expose
:name
expose
:name
expose
:id
expose
:id
expose
:ref
,
as: :branch
expose
:ref
,
as: :branch
expose
:short_sha
expose
:short_sha
expose
:started_at
,
as: :date
expose
:duration
,
as: :total_time
expose
:author
,
using:
UserEntity
expose
:author
,
using:
UserEntity
expose
:started_at
,
as: :date
do
|
build
|
interval_in_words
(
build
[
:started_at
])
end
expose
:duration
,
as: :total_time
do
|
build
|
distance_of_time_in_words
(
build
[
:duration
].
to_f
)
end
expose
:branch
do
expose
:branch
do
expose
:ref
,
as: :name
expose
:ref
,
as: :name
...
...
app/serializers/analytics_generic_entity.rb
View file @
8743e59f
class
AnalyticsGenericEntity
<
Grape
::
Entity
class
AnalyticsGenericEntity
<
Grape
::
Entity
include
RequestAwareEntity
include
RequestAwareEntity
include
ActionView
::
Helpers
::
DateHelper
include
EntityDateHelper
expose
:title
expose
:title
expose
:iid
expose
:iid
expose
:state
,
if:
->
(
_instance
,
options
)
{
options
[
:request
].
entity
==
:merge_request
}
expose
:author
,
using:
UserEntity
expose
:author
,
using:
UserEntity
expose
:total_time
do
|
object
|
expose
:total_time
do
|
object
|
...
@@ -24,8 +24,4 @@ class AnalyticsGenericEntity < Grape::Entity
...
@@ -24,8 +24,4 @@ class AnalyticsGenericEntity < Grape::Entity
def
url_to
(
route
,
id
)
def
url_to
(
route
,
id
)
public_send
(
"
#{
route
}
_url"
,
request
.
project
.
namespace
,
request
.
project
,
id
)
public_send
(
"
#{
route
}
_url"
,
request
.
project
.
namespace
,
request
.
project
,
id
)
end
end
def
interval_in_words
(
diff
)
"
#{
distance_of_time_in_words
(
diff
.
to_f
)
}
ago"
end
end
end
app/serializers/entity_date_helper.rb
0 → 100644
View file @
8743e59f
module
EntityDateHelper
include
ActionView
::
Helpers
::
DateHelper
def
interval_in_words
(
diff
)
"
#{
distance_of_time_in_words
(
diff
.
to_f
)
}
ago"
end
end
\ No newline at end of file
lib/gitlab/cycle_analytics/events.rb
View file @
8743e59f
...
@@ -34,7 +34,7 @@ module Gitlab
...
@@ -34,7 +34,7 @@ module Gitlab
end
end
def
review_events
def
review_events
@fetcher
.
fetch
(
stage: :review
).
map
{
|
event
|
parse_event
(
event
)
}
@fetcher
.
fetch
(
stage: :review
).
map
{
|
event
|
parse_event
(
event
,
entity: :merge_request
)
}
end
end
def
staging_events
def
staging_events
...
@@ -44,7 +44,7 @@ module Gitlab
...
@@ -44,7 +44,7 @@ module Gitlab
end
end
def
production_events
def
production_events
@fetcher
.
fetch
(
stage: :production
).
each
{
|
event
|
parse_event
(
event
)
}
@fetcher
.
fetch
(
stage: :production
).
map
{
|
event
|
parse_event
(
event
)
}
end
end
private
private
...
...
lib/gitlab/cycle_analytics/query_config.rb
View file @
8743e59f
...
@@ -67,7 +67,7 @@ module Gitlab
...
@@ -67,7 +67,7 @@ module Gitlab
projections:
[
mr_table
[
:title
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:iid
],
mr_table
[
:id
],
mr_table
[
:id
],
mr_table
[
:created_at
]
.
as
(
'opened_at'
)
,
mr_table
[
:created_at
],
mr_table
[
:state
],
mr_table
[
:state
],
mr_table
[
:author_id
]]
mr_table
[
:author_id
]]
}
}
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
8743e59f
...
@@ -60,15 +60,15 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -60,15 +60,15 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
"has the author's URL"
do
it
"has the author's URL"
do
expect
(
subject
.
plan_events
.
first
[
:author
_profile
_url
]).
not_to
be_nil
expect
(
subject
.
plan_events
.
first
[
:author
][
:web
_url
]).
not_to
be_nil
end
end
it
"has the author's avatar URL"
do
it
"has the author's avatar URL"
do
expect
(
subject
.
plan_events
.
first
[
:author
_
avatar_url
]).
not_to
be_nil
expect
(
subject
.
plan_events
.
first
[
:author
][
:
avatar_url
]).
not_to
be_nil
end
end
it
"has the author's name"
do
it
"has the author's name"
do
expect
(
subject
.
plan_events
.
first
[
:author
_name
]).
not_to
be_nil
expect
(
subject
.
plan_events
.
first
[
:author
][
:name
]).
to
eq
(
context
.
author
.
name
)
end
end
end
end
...
@@ -94,15 +94,15 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -94,15 +94,15 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
"has the author's URL"
do
it
"has the author's URL"
do
expect
(
subject
.
code_events
.
first
[
:author
_profile
_url
]).
not_to
be_nil
expect
(
subject
.
code_events
.
first
[
:author
][
:web
_url
]).
not_to
be_nil
end
end
it
"has the author's avatar URL"
do
it
"has the author's avatar URL"
do
expect
(
subject
.
code_events
.
first
[
:author
_
avatar_url
]).
not_to
be_nil
expect
(
subject
.
code_events
.
first
[
:author
][
:
avatar_url
]).
not_to
be_nil
end
end
it
"has the author's name"
do
it
"has the author's name"
do
expect
(
subject
.
code_events
.
first
[
:author
_name
]).
to
eq
(
contex
t
.
author
.
name
)
expect
(
subject
.
code_events
.
first
[
:author
][
:name
]).
to
eq
(
MergeRequest
.
firs
t
.
author
.
name
)
end
end
end
end
...
@@ -184,19 +184,19 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -184,19 +184,19 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
'has a created_at timestamp'
do
it
'has a created_at timestamp'
do
expect
(
subject
.
review_events
.
first
[
:
open
ed_at
]).
not_to
be_nil
expect
(
subject
.
review_events
.
first
[
:
creat
ed_at
]).
not_to
be_nil
end
end
it
"has the author's URL"
do
it
"has the author's URL"
do
expect
(
subject
.
review_events
.
first
[
:author
_profile
_url
]).
not_to
be_nil
expect
(
subject
.
review_events
.
first
[
:author
][
:web
_url
]).
not_to
be_nil
end
end
it
"has the author's avatar URL"
do
it
"has the author's avatar URL"
do
expect
(
subject
.
review_events
.
first
[
:author
_
avatar_url
]).
not_to
be_nil
expect
(
subject
.
review_events
.
first
[
:author
][
:
avatar_url
]).
not_to
be_nil
end
end
it
"has the author's name"
do
it
"has the author's name"
do
expect
(
subject
.
review_events
.
first
[
:author
_
name
]).
to
eq
(
MergeRequest
.
first
.
author
.
name
)
expect
(
subject
.
review_events
.
first
[
:author
][
:
name
]).
to
eq
(
MergeRequest
.
first
.
author
.
name
)
end
end
end
end
...
@@ -237,11 +237,11 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -237,11 +237,11 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
'has the branch URL'
do
it
'has the branch URL'
do
expect
(
subject
.
staging_events
.
first
[
:branch
_
url
]).
not_to
be_nil
expect
(
subject
.
staging_events
.
first
[
:branch
][
:
url
]).
not_to
be_nil
end
end
it
'has the short SHA'
do
it
'has the short SHA'
do
expect
(
subject
.
staging_events
.
first
[
:sha
]).
not_to
be_nil
expect
(
subject
.
staging_events
.
first
[
:sh
ort_sh
a
]).
not_to
be_nil
end
end
it
'has the commit URL'
do
it
'has the commit URL'
do
...
@@ -256,8 +256,16 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -256,8 +256,16 @@ describe Gitlab::CycleAnalytics::Events do
expect
(
subject
.
staging_events
.
first
[
:total_time
]).
not_to
be_nil
expect
(
subject
.
staging_events
.
first
[
:total_time
]).
not_to
be_nil
end
end
it
'has the author name'
do
it
"has the author's URL"
do
expect
(
subject
.
staging_events
.
first
[
:author_name
]).
not_to
be_nil
expect
(
subject
.
staging_events
.
first
[
:author
][
:web_url
]).
not_to
be_nil
end
it
"has the author's avatar URL"
do
expect
(
subject
.
staging_events
.
first
[
:author
][
:avatar_url
]).
not_to
be_nil
end
it
"has the author's name"
do
expect
(
subject
.
staging_events
.
first
[
:author
][
:name
]).
to
eq
(
MergeRequest
.
first
.
author
.
name
)
end
end
end
end
...
@@ -290,15 +298,15 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -290,15 +298,15 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
"has the author's URL"
do
it
"has the author's URL"
do
expect
(
subject
.
production_events
.
first
[
:author
_profile
_url
]).
not_to
be_nil
expect
(
subject
.
production_events
.
first
[
:author
][
:web
_url
]).
not_to
be_nil
end
end
it
"has the author's avatar URL"
do
it
"has the author's avatar URL"
do
expect
(
subject
.
production_events
.
first
[
:author
_
avatar_url
]).
not_to
be_nil
expect
(
subject
.
production_events
.
first
[
:author
][
:
avatar_url
]).
not_to
be_nil
end
end
it
"has the author's name"
do
it
"has the author's name"
do
expect
(
subject
.
production_events
.
first
[
:author
_
name
]).
to
eq
(
context
.
author
.
name
)
expect
(
subject
.
production_events
.
first
[
:author
][
:
name
]).
to
eq
(
context
.
author
.
name
)
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