diff options
author | James Lopez <james@jameslopez.es> | 2016-10-27 17:52:42 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-17 08:22:56 +0100 |
commit | ca9ae8bf63ff94c68143823046ab2a7466f30b1c (patch) | |
tree | e93849d907a53cbe1bc568c507e4a89736584986 | |
parent | 32679232635dbd0d196a91d0788ee1135ff56b43 (diff) | |
download | gitlab-ce-ca9ae8bf63ff94c68143823046ab2a7466f30b1c.tar.gz |
add email to user related queries so it can be used for displaying avatar in the UI
-rw-r--r-- | app/controllers/projects/cycle_analytics/events_controller.rb | 16 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/events.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/cycle_analytics/events_fetcher.rb | 8 | ||||
-rw-r--r-- | spec/lib/gitlab/cycle_analytics/events_spec.rb | 16 |
4 files changed, 28 insertions, 13 deletions
diff --git a/app/controllers/projects/cycle_analytics/events_controller.rb b/app/controllers/projects/cycle_analytics/events_controller.rb index 142cbc344a5..49c7303dccc 100644 --- a/app/controllers/projects/cycle_analytics/events_controller.rb +++ b/app/controllers/projects/cycle_analytics/events_controller.rb @@ -1,5 +1,5 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationController - #before_action :authorize_read_cycle_analytics! + # before_action :authorize_read_cycle_analytics! def issue render_events(events.issue_events) @@ -41,12 +41,12 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll # TODO refactor this def start_date case events_params[:start_date] - when '30' then - 30.days.ago - when '90' then - 90.days.ago - else - 90.days.ago + when '30' then + 30.days.ago + when '90' then + 90.days.ago + else + 90.days.ago end end @@ -59,4 +59,4 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll { start_date: params[:events][:start_date] } end -end
\ No newline at end of file +end diff --git a/lib/gitlab/cycle_analytics/events.rb b/lib/gitlab/cycle_analytics/events.rb index 912694fa1ad..08070c2bac2 100644 --- a/lib/gitlab/cycle_analytics/events.rb +++ b/lib/gitlab/cycle_analytics/events.rb @@ -10,7 +10,6 @@ module Gitlab end # TODO: backend pagination - specially for commits, etc... - # TODO figure out what the frontend needs for displaying the avatar def issue_events @fetcher.fetch(stage: :issue).each { |event| parse_event(event) } diff --git a/lib/gitlab/cycle_analytics/events_fetcher.rb b/lib/gitlab/cycle_analytics/events_fetcher.rb index 03b1878dc1c..2686ac353d6 100644 --- a/lib/gitlab/cycle_analytics/events_fetcher.rb +++ b/lib/gitlab/cycle_analytics/events_fetcher.rb @@ -8,7 +8,7 @@ module Gitlab start_time_attrs: issue_table[:created_at], end_time_attrs: [issue_metrics_table[:first_associated_with_milestone_at], issue_metrics_table[:first_added_to_board_at]], - projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name]] + projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name], user_table[:email]] }, plan: { start_time_attrs: issue_metrics_table[:first_associated_with_milestone_at], @@ -19,7 +19,7 @@ module Gitlab code: { start_time_attrs: issue_metrics_table[:first_mentioned_in_commit_at], end_time_attrs: mr_table[:created_at], - projections: [mr_table[:title], mr_table[:iid], mr_table[:created_at], user_table[:name]], + projections: [mr_table[:title], mr_table[:iid], mr_table[:created_at], user_table[:name], user_table[:email]], order: mr_table[:created_at] }, test: { @@ -31,7 +31,7 @@ module Gitlab review: { start_time_attrs: mr_table[:created_at], end_time_attrs: mr_metrics_table[:merged_at], - projections: [mr_table[:title], mr_table[:iid], mr_table[:created_at], user_table[:name]] + projections: [mr_table[:title], mr_table[:iid], mr_table[:created_at], user_table[:name], user_table[:email]] }, staging: { start_time_attrs: mr_metrics_table[:merged_at], @@ -41,7 +41,7 @@ module Gitlab production: { start_time_attrs: issue_table[:created_at], end_time_attrs: mr_metrics_table[:first_deployed_to_production_at], - projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name]] + projections: [issue_table[:title], issue_table[:iid], issue_table[:created_at], user_table[:name], user_table[:email]] }, }.freeze diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb index 410310d3029..7d544dbdb19 100644 --- a/spec/lib/gitlab/cycle_analytics/events_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb @@ -30,6 +30,10 @@ describe Gitlab::CycleAnalytics::Events do expect(subject.issue_events.first['created_at']).to end_with('ago') end + it "has the author's email" do + expect(subject.issue_events.first['email']).to eq(context.author.email) + end + it "has the author's name" do expect(subject.issue_events.first['name']).to eq(context.author.name) end @@ -70,6 +74,10 @@ describe Gitlab::CycleAnalytics::Events do expect(subject.code_events.first['created_at']).to end_with('ago') end + it "has the author's email" do + expect(subject.code_events.first['email']).to eq(context.author.email) + end + it "has the author's name" do expect(subject.code_events.first['name']).to eq(context.author.name) end @@ -118,6 +126,10 @@ describe Gitlab::CycleAnalytics::Events do expect(subject.review_events.first['created_at']).to end_with('ago') end + it "has the author's email" do + expect(subject.review_events.first['email']).to eq(MergeRequest.first.author.email) + end + it "has the author's name" do expect(subject.review_events.first['name']).to eq(MergeRequest.first.author.name) end @@ -173,6 +185,10 @@ describe Gitlab::CycleAnalytics::Events do expect(subject.production_events.first['created_at']).to end_with('ago') end + it "has the author's email" do + expect(subject.production_events.first['email']).to eq(context.author.email) + end + it "has the author's name" do expect(subject.production_events.first['name']).to eq(context.author.name) end |