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
3b179bc3
Commit
3b179bc3
authored
Nov 14, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP - refactored events to use build serializer, related spec passing
parent
81d0146c
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
68 deletions
+79
-68
app/serializers/analytics_build_entity.rb
app/serializers/analytics_build_entity.rb
+10
-4
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+3
-3
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+59
-59
spec/serializers/analytics_build_entity_spec.rb
spec/serializers/analytics_build_entity_spec.rb
+7
-2
No files found.
app/serializers/analytics_build_entity.rb
View file @
3b179bc3
...
@@ -2,17 +2,23 @@ class AnalyticsBuildEntity < Grape::Entity
...
@@ -2,17 +2,23 @@ class AnalyticsBuildEntity < Grape::Entity
include
RequestAwareEntity
include
RequestAwareEntity
expose
:name
expose
:name
expose
:id
expose
:ref
,
as: :branch
expose
:ref
,
as: :branch
expose
:short_sha
expose
:short_sha
expose
:started_at
,
as: :date
expose
:started_at
,
as: :date
expose
:duration
,
as: :total_time
expose
:duration
,
as: :total_time
expose
:author
,
using:
UserEntity
expose
:url
do
|
build
|
expose
:branch
do
url_to
(
:namespace_project_build
,
build
)
expose
:ref
,
as: :name
expose
:url
do
|
build
|
url_to
(
:namespace_project_tree
,
build
,
build
.
ref
)
end
end
end
expose
:
branch_
url
do
|
build
|
expose
:url
do
|
build
|
url_to
(
:namespace_project_
tree
,
build
,
build
.
ref
)
url_to
(
:namespace_project_
build
,
build
)
end
end
expose
:commit_url
do
|
build
|
expose
:commit_url
do
|
build
|
...
...
lib/gitlab/cycle_analytics/events.rb
View file @
3b179bc3
...
@@ -30,7 +30,7 @@ module Gitlab
...
@@ -30,7 +30,7 @@ module Gitlab
end
end
def
test_events
def
test_events
@fetcher
.
fetch
(
stage: :test
).
each
do
|
event
|
@fetcher
.
fetch
(
stage: :test
).
map
do
|
event
|
parse_build_event
(
event
)
parse_build_event
(
event
)
end
end
end
end
...
@@ -40,7 +40,7 @@ module Gitlab
...
@@ -40,7 +40,7 @@ module Gitlab
end
end
def
staging_events
def
staging_events
@fetcher
.
fetch
(
stage: :staging
).
each
do
|
event
|
@fetcher
.
fetch
(
stage: :staging
).
map
do
|
event
|
parse_build_event
(
event
)
parse_build_event
(
event
)
end
end
end
end
...
@@ -64,7 +64,7 @@ module Gitlab
...
@@ -64,7 +64,7 @@ module Gitlab
def
parse_build_event
(
event
)
def
parse_build_event
(
event
)
build
=
::
Ci
::
Build
.
find
(
event
[
'id'
])
build
=
::
Ci
::
Build
.
find
(
event
[
'id'
])
#event['author_name'] = build.author.try(:name)
AnalyticsBuildSerializer
.
new
(
project:
@project
).
represent
(
build
).
as_json
end
end
def
first_time_reference_commit
(
commits
,
event
)
def
first_time_reference_commit
(
commits
,
event
)
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
3b179bc3
This diff is collapsed.
Click to expand it.
spec/serializers/analytics_build_entity_spec.rb
View file @
3b179bc3
...
@@ -6,14 +6,19 @@ describe AnalyticsBuildEntity do
...
@@ -6,14 +6,19 @@ describe AnalyticsBuildEntity do
end
end
context
'when build is a regular job'
do
context
'when build is a regular job'
do
let
(
:build
)
{
create
(
:ci_build
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
,
author:
user
)
}
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
it
'contains
url to build page and retry action
'
do
it
'contains
URLs
'
do
expect
(
subject
).
to
include
(
:url
,
:branch_url
,
:commit_url
)
expect
(
subject
).
to
include
(
:url
,
:branch_url
,
:commit_url
)
end
end
it
'contains the author'
do
expect
(
subject
).
to
include
(
:author
)
end
it
'does not contain sensitive information'
do
it
'does not contain sensitive information'
do
expect
(
subject
).
not_to
include
(
/token/
)
expect
(
subject
).
not_to
include
(
/token/
)
expect
(
subject
).
not_to
include
(
/variables/
)
expect
(
subject
).
not_to
include
(
/variables/
)
...
...
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