Commit 11bad33a authored by James Lopez's avatar James Lopez

added missing fields to code events and updated spec

parent 1b5b2eac
...@@ -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'])
......
...@@ -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
......
...@@ -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
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment