diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 00:07:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-08 00:07:54 +0300 |
commit | 8c8b94e7116fa478ad490bd14c09565d23097f57 (patch) | |
tree | 9e4637aa0fe498a5523c86932b87ff691ec72af6 /app/controllers | |
parent | eadb77d89f5f7d445bfd326f18873168f4719f12 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
4 files changed, 35 insertions, 19 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index fbf63997b15..f7e33c09928 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -6,9 +6,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController before_action :set_application_setting before_action :whitelist_query_limiting, only: [:usage_data] - VALID_SETTING_PANELS = %w(general integrations repository templates + VALID_SETTING_PANELS = %w(general integrations repository ci_cd reporting metrics_and_profiling - network geo preferences).freeze + network preferences).freeze VALID_SETTING_PANELS.each do |action| define_method(action) { perform_update if submitted? } @@ -145,10 +145,15 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end def render_update_error - action = VALID_SETTING_PANELS.include?(action_name) ? action_name : :general + action = valid_setting_panels.include?(action_name) ? action_name : :general render action end + + # overridden in EE + def valid_setting_panels + VALID_SETTING_PANELS + end end Admin::ApplicationSettingsController.prepend_if_ee('EE::Admin::ApplicationSettingsController') diff --git a/app/controllers/concerns/cycle_analytics_params.rb b/app/controllers/concerns/cycle_analytics_params.rb index b970bdc544e..1645af695be 100644 --- a/app/controllers/concerns/cycle_analytics_params.rb +++ b/app/controllers/concerns/cycle_analytics_params.rb @@ -3,8 +3,20 @@ module CycleAnalyticsParams extend ActiveSupport::Concern + def cycle_analytics_project_params + return {} unless params[:cycle_analytics].present? + + params[:cycle_analytics].permit(:start_date, :created_after, :created_before, :branch_name) + end + + def cycle_analytics_group_params + return {} unless params[:cycle_analytics].present? + + params[:cycle_analytics].permit(:start_date, :created_after, :created_before, project_ids: []) + end + def options(params) - @options ||= { from: start_date(params), current_user: current_user } + @options ||= { from: start_date(params), current_user: current_user }.merge(date_range(params)) end def start_date(params) @@ -17,6 +29,17 @@ module CycleAnalyticsParams 90.days.ago end end + + def date_range(params) + {}.tap do |date_range_params| + date_range_params[:from] = to_utc_time(params[:created_after]).beginning_of_day if params[:created_after] + date_range_params[:to] = to_utc_time(params[:created_before]).end_of_day if params[:created_before] + end.compact + end + + def to_utc_time(field) + Date.parse(field).to_time.utc + end end CycleAnalyticsParams.prepend_if_ee('EE::CycleAnalyticsParams') diff --git a/app/controllers/projects/cycle_analytics/events_controller.rb b/app/controllers/projects/cycle_analytics/events_controller.rb index 926592b9681..673f53c221b 100644 --- a/app/controllers/projects/cycle_analytics/events_controller.rb +++ b/app/controllers/projects/cycle_analytics/events_controller.rb @@ -23,7 +23,7 @@ module Projects end def test - options(cycle_analytics_params)[:branch] = cycle_analytics_params[:branch_name] + options(cycle_analytics_project_params)[:branch] = cycle_analytics_project_params[:branch_name] render_events(cycle_analytics[:test].events) end @@ -50,13 +50,7 @@ module Projects end def cycle_analytics - @cycle_analytics ||= ::CycleAnalytics::ProjectLevel.new(project, options: options(cycle_analytics_params)) - end - - def cycle_analytics_params - return {} unless params[:cycle_analytics].present? - - params[:cycle_analytics].permit(:start_date, :branch_name) + @cycle_analytics ||= ::CycleAnalytics::ProjectLevel.new(project, options: options(cycle_analytics_project_params)) end end end diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb index b9d7dbd37be..f13c75ac4cc 100644 --- a/app/controllers/projects/cycle_analytics_controller.rb +++ b/app/controllers/projects/cycle_analytics_controller.rb @@ -9,7 +9,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController before_action :authorize_read_cycle_analytics! def show - @cycle_analytics = ::CycleAnalytics::ProjectLevel.new(@project, options: options(cycle_analytics_params)) + @cycle_analytics = ::CycleAnalytics::ProjectLevel.new(@project, options: options(cycle_analytics_project_params)) @cycle_analytics_no_data = @cycle_analytics.no_stats? @@ -27,12 +27,6 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController private - def cycle_analytics_params - return {} unless params[:cycle_analytics].present? - - params[:cycle_analytics].permit(:start_date) - end - def cycle_analytics_json { summary: @cycle_analytics.summary, |