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
Boxiang Sun
gitlab-ce
Commits
11bad33a
Commit
11bad33a
authored
Nov 03, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added missing fields to code events and updated spec
parent
1b5b2eac
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+3
-3
lib/gitlab/cycle_analytics/query_config.rb
lib/gitlab/cycle_analytics/query_config.rb
+7
-4
lib/gitlab/light_url_builder.rb
lib/gitlab/light_url_builder.rb
+10
-0
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+7
-3
No files found.
lib/gitlab/cycle_analytics/events.rb
View file @
11bad33a
...
@@ -27,7 +27,7 @@ module Gitlab
...
@@ -27,7 +27,7 @@ module Gitlab
end
end
def
code_events
def
code_events
@fetcher
.
fetch
(
stage: :code
).
each
{
|
event
|
parse_event
(
event
)
}
@fetcher
.
fetch
(
stage: :code
).
each
{
|
event
|
parse_event
(
event
,
entity: :merge_request
)
}
end
end
def
test_events
def
test_events
...
@@ -54,8 +54,8 @@ module Gitlab
...
@@ -54,8 +54,8 @@ module Gitlab
private
private
def
parse_event
(
event
)
def
parse_event
(
event
,
entity: :issue
)
event
[
'url'
]
=
Gitlab
::
LightUrlBuilder
.
build
(
entity:
:issue
,
project:
@project
,
id:
event
[
'id'
])
event
[
'url'
]
=
Gitlab
::
LightUrlBuilder
.
build
(
entity:
entity
,
project:
@project
,
id:
event
[
'id'
])
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'created_at'
]
=
interval_in_words
(
event
[
'created_at'
])
event
[
'created_at'
]
=
interval_in_words
(
event
[
'created_at'
])
event
[
'author_profile_url'
]
=
Gitlab
::
LightUrlBuilder
.
build
(
entity: :user
,
id:
event
[
'author_username'
])
event
[
'author_profile_url'
]
=
Gitlab
::
LightUrlBuilder
.
build
(
entity: :user
,
id:
event
[
'author_username'
])
...
...
lib/gitlab/cycle_analytics/query_config.rb
View file @
11bad33a
...
@@ -23,7 +23,6 @@ module Gitlab
...
@@ -23,7 +23,6 @@ module Gitlab
issue_table
[
:iid
],
issue_table
[
:iid
],
issue_table
[
:id
],
issue_table
[
:id
],
issue_table
[
:created_at
],
issue_table
[
:created_at
],
issue_table
[
:state
],
user_table
[
:name
].
as
(
'author_name'
),
user_table
[
:name
].
as
(
'author_name'
),
user_table
[
:username
].
as
(
'author_username'
),
user_table
[
:username
].
as
(
'author_username'
),
user_table
[
:id
].
as
(
'author_id'
)]
user_table
[
:id
].
as
(
'author_id'
)]
...
@@ -41,10 +40,14 @@ module Gitlab
...
@@ -41,10 +40,14 @@ module Gitlab
def
code
def
code
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
{
start_time_attrs:
issue_metrics_table
[
:first_mentioned_in_commit_at
],
end_time_attrs:
mr_table
[
:created_at
],
end_time_attrs:
mr_table
[
:created_at
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
projections:
[
mr_table
[
:title
],
mr_table
[
:iid
],
mr_table
[
:id
],
mr_table
[
:created_at
],
mr_table
[
:created_at
],
user_table
[
:name
],
mr_table
[
:state
],
user_table
[
:email
]],
user_table
[
:name
].
as
(
'author_name'
),
user_table
[
:username
].
as
(
'author_username'
),
user_table
[
:id
].
as
(
'author_id'
)],
order:
mr_table
[
:created_at
]
order:
mr_table
[
:created_at
]
}
}
end
end
...
...
lib/gitlab/light_url_builder.rb
View file @
11bad33a
...
@@ -25,6 +25,8 @@ module Gitlab
...
@@ -25,6 +25,8 @@ module Gitlab
user_avatar_url
user_avatar_url
when
:commit_url
when
:commit_url
commit_url
commit_url
when
:merge_request
mr_url
else
else
raise
NotImplementedError
.
new
(
"No URL builder defined for
#{
object
.
class
}
"
)
raise
NotImplementedError
.
new
(
"No URL builder defined for
#{
object
.
class
}
"
)
end
end
...
@@ -51,5 +53,13 @@ module Gitlab
...
@@ -51,5 +53,13 @@ module Gitlab
id:
@id
id:
@id
}.
merge!
(
@opts
))
}.
merge!
(
@opts
))
end
end
def
mr_url
namespace_project_merge_request_url
({
namespace_id:
@project
.
namespace
,
project_id:
@project
,
id:
@id
}.
merge!
(
@opts
))
end
end
end
end
end
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
11bad33a
...
@@ -89,12 +89,16 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -89,12 +89,16 @@ describe Gitlab::CycleAnalytics::Events do
expect
(
subject
.
code_events
.
first
[
'created_at'
]).
to
end_with
(
'ago'
)
expect
(
subject
.
code_events
.
first
[
'created_at'
]).
to
end_with
(
'ago'
)
end
end
it
"has the author's email"
do
it
"has the author's URL"
do
expect
(
subject
.
code_events
.
first
[
'email'
]).
to
eq
(
context
.
author
.
email
)
expect
(
subject
.
code_events
.
first
[
'author_profile_url'
]).
not_to
be_nil
end
it
"has the author's avatar URL"
do
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
[
'name'
]).
to
eq
(
context
.
author
.
name
)
expect
(
subject
.
code_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