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
Jérome Perrin
gitlab-ce
Commits
f5600997
Commit
f5600997
authored
Nov 15, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue events and related spec - now using generic serializer for a hash
parent
747e5c3b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
11 deletions
+16
-11
app/serializers/analytics_generic_entity.rb
app/serializers/analytics_generic_entity.rb
+2
-3
app/serializers/analytics_generic_serializer.rb
app/serializers/analytics_generic_serializer.rb
+6
-0
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+4
-4
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+3
-3
spec/serializers/analytics_generic_serializer_spec.rb
spec/serializers/analytics_generic_serializer_spec.rb
+1
-1
No files found.
app/serializers/analytics_generic_entity.rb
View file @
f5600997
...
...
@@ -5,14 +5,13 @@ class AnalyticsGenericEntity < Grape::Entity
expose
:title
expose
:iid
expose
:started_at
,
as: :date
expose
:author
,
using:
UserEntity
expose
:total_time
do
|
object
|
distance_of_time_in_words
(
object
[
:total_time
].
to_f
)
end
expose
(
:
date
)
do
|
object
|
expose
(
:
created_at
)
do
|
object
|
interval_in_words
(
object
[
:created_at
])
end
...
...
@@ -22,7 +21,7 @@ class AnalyticsGenericEntity < Grape::Entity
private
def
url_to
(
route
,
id
=
nil
)
def
url_to
(
route
,
id
)
public_send
(
"
#{
route
}
_url"
,
request
.
project
.
namespace
,
request
.
project
,
id
)
end
...
...
app/serializers/analytics_generic_serializer.rb
View file @
f5600997
class
AnalyticsGenericSerializer
<
BaseSerializer
entity
AnalyticsGenericEntity
def
represent
(
resource
,
opts
=
{})
resource
.
symbolize_keys!
super
(
resource
,
opts
)
end
end
lib/gitlab/cycle_analytics/events.rb
View file @
f5600997
...
...
@@ -7,7 +7,7 @@ module Gitlab
end
def
issue_events
@fetcher
.
fetch
(
stage: :issue
).
each
{
|
event
|
parse_event
(
event
)
}
@fetcher
.
fetch
(
stage: :issue
).
map
{
|
event
|
parse_event
(
event
)
}
end
def
plan_events
...
...
@@ -24,7 +24,7 @@ module Gitlab
end
def
code_events
@fetcher
.
fetch
(
stage: :code
).
each
{
|
event
|
parse_event
(
event
,
entity: :merge_request
)
}
@fetcher
.
fetch
(
stage: :code
).
map
{
|
event
|
parse_event
(
event
,
entity: :merge_request
)
}
end
def
test_events
...
...
@@ -34,7 +34,7 @@ module Gitlab
end
def
review_events
@fetcher
.
fetch
(
stage: :review
).
each
{
|
event
|
parse_event
(
event
)
}
@fetcher
.
fetch
(
stage: :review
).
map
{
|
event
|
parse_event
(
event
)
}
end
def
staging_events
...
...
@@ -50,7 +50,7 @@ module Gitlab
private
def
parse_event
(
event
,
entity: :issue
)
event
[
'author'
]
=
User
.
find
(
event
.
remov
e
(
'author_id'
))
event
[
'author'
]
=
User
.
find
(
event
.
delet
e
(
'author_id'
))
AnalyticsGenericSerializer
.
new
(
project:
@project
,
entity:
entity
).
represent
(
event
).
as_json
end
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
f5600997
...
...
@@ -34,15 +34,15 @@ describe Gitlab::CycleAnalytics::Events do
end
it
"has the author's URL"
do
expect
(
subject
.
issue_events
.
first
[
:author
_profile
_url
]).
not_to
be_nil
expect
(
subject
.
issue_events
.
first
[
:author
][
:web
_url
]).
not_to
be_nil
end
it
"has the author's avatar URL"
do
expect
(
subject
.
issue_events
.
first
[
:author
_
avatar_url
]).
not_to
be_nil
expect
(
subject
.
issue_events
.
first
[
:author
][
:
avatar_url
]).
not_to
be_nil
end
it
"has the author's name"
do
expect
(
subject
.
issue_events
.
first
[
:author
_
name
]).
to
eq
(
context
.
author
.
name
)
expect
(
subject
.
issue_events
.
first
[
:author
][
:
name
]).
to
eq
(
context
.
author
.
name
)
end
end
...
...
spec/serializers/analytics_generic_serializer_spec.rb
View file @
f5600997
...
...
@@ -27,7 +27,7 @@ describe AnalyticsGenericSerializer do
end
it
'contains important elements of analyticsBuild'
do
expect
(
json
).
to
include
(
:title
,
:iid
,
:
date
,
:total_time
,
:url
,
:author
)
expect
(
json
).
to
include
(
:title
,
:iid
,
:
created_at
,
:total_time
,
:url
,
:author
)
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