diff options
author | James Lopez <james@jameslopez.es> | 2016-11-21 10:48:07 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-21 10:49:05 +0100 |
commit | 0fd397bba1a36136c3737165c9057bc59dcbca77 (patch) | |
tree | 5cfbefc6f918b96d5a1464c6c64f910661880c83 /app | |
parent | 9aded5c8d43cf113b03e2d8fd04a32c4b24af24d (diff) | |
download | gitlab-ce-0fd397bba1a36136c3737165c9057bc59dcbca77.tar.gz |
Added permissions per stage to cycle analytics endpoint
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/cycle_analytics_controller.rb | 5 | ||||
-rw-r--r-- | app/models/cycle_analytics.rb | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb index 96eb75a0547..8567b074f11 100644 --- a/app/controllers/projects/cycle_analytics_controller.rb +++ b/app/controllers/projects/cycle_analytics_controller.rb @@ -6,7 +6,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController before_action :authorize_read_cycle_analytics! def show - @cycle_analytics = ::CycleAnalytics.new(@project, from: start_date(cycle_analytics_params)) + @cycle_analytics = ::CycleAnalytics.new(@project, from: start_date(cycle_analytics_params), user: current_user) respond_to do |format| format.html @@ -54,7 +54,8 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController { summary: summary, - stats: stats + stats: stats, + permissions: @cycle_analytics.permissions } end end diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb index 314a1ce9b63..a10e96d53bf 100644 --- a/app/models/cycle_analytics.rb +++ b/app/models/cycle_analytics.rb @@ -1,7 +1,10 @@ class CycleAnalytics - def initialize(project, from:) + STAGES = %i[issue plan code test review staging production].freeze + + def initialize(project, from:, user:) @project = project @from = from + @user = user @fetcher = Gitlab::CycleAnalytics::MetricsFetcher.new(project: project, from: from, branch: nil) end @@ -9,6 +12,10 @@ class CycleAnalytics @summary ||= Summary.new(@project, from: @from) end + def permissions + Gitlab::CycleAnalytics::Permissions.get(user: @user, project: @project) + end + def issue @fetcher.calculate_metric(:issue, Issue.arel_table[:created_at], |