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
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
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