BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
9 deletions
+20
-9
analytics_build_entity.rb
app/serializers/analytics_build_entity.rb
+10
-4
events.rb
lib/gitlab/cycle_analytics/events.rb
+3
-3
events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+0
-0
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
include
RequestAwareEntity
expose
:name
expose
:id
expose
:ref
,
as: :branch
expose
:short_sha
expose
:started_at
,
as: :date
expose
:duration
,
as: :total_time
expose
:author
,
using:
UserEntity
expose
:url
do
|
build
|
url_to
(
:namespace_project_build
,
build
)
expose
:branch
do
expose
:ref
,
as: :name
expose
:url
do
|
build
|
url_to
(
:namespace_project_tree
,
build
,
build
.
ref
)
end
end
expose
:
branch_
url
do
|
build
|
url_to
(
:namespace_project_
tree
,
build
,
build
.
ref
)
expose
:url
do
|
build
|
url_to
(
:namespace_project_
build
,
build
)
end
expose
:commit_url
do
|
build
|
...
...
lib/gitlab/cycle_analytics/events.rb
View file @
3b179bc3
...
...
@@ -30,7 +30,7 @@ module Gitlab
end
def
test_events
@fetcher
.
fetch
(
stage: :test
).
each
do
|
event
|
@fetcher
.
fetch
(
stage: :test
).
map
do
|
event
|
parse_build_event
(
event
)
end
end
...
...
@@ -40,7 +40,7 @@ module Gitlab
end
def
staging_events
@fetcher
.
fetch
(
stage: :staging
).
each
do
|
event
|
@fetcher
.
fetch
(
stage: :staging
).
map
do
|
event
|
parse_build_event
(
event
)
end
end
...
...
@@ -64,7 +64,7 @@ module Gitlab
def
parse_build_event
(
event
)
build
=
::
Ci
::
Build
.
find
(
event
[
'id'
])
#event['author_name'] = build.author.try(:name)
AnalyticsBuildSerializer
.
new
(
project:
@project
).
represent
(
build
).
as_json
end
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
end
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
}
it
'contains
url to build page and retry action
'
do
it
'contains
URLs
'
do
expect
(
subject
).
to
include
(
:url
,
:branch_url
,
:commit_url
)
end
it
'contains the author'
do
expect
(
subject
).
to
include
(
:author
)
end
it
'does not contain sensitive information'
do
expect
(
subject
).
not_to
include
(
/token/
)
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