From cc452b401a66e2b3145f9c155c5969fca959f098 Mon Sep 17 00:00:00 2001 From: Dani Donisa Date: Thu, 14 Mar 2024 09:45:48 +0100 Subject: [PATCH] Refactor action related code --- .../controllers/webui/request_controller.rb | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/api/app/controllers/webui/request_controller.rb b/src/api/app/controllers/webui/request_controller.rb index 9d37464b50d..1d5506a199e 100644 --- a/src/api/app/controllers/webui/request_controller.rb +++ b/src/api/app/controllers/webui/request_controller.rb @@ -28,6 +28,7 @@ class Webui::RequestController < Webui::WebuiController before_action :cache_diff_data, only: %i[show build_results rpm_lint changes mentioned_issues], if: -> { Flipper.enabled?(:request_show_redesign, User.session) } before_action :check_beta_user_redirect, only: %i[build_results rpm_lint changes mentioned_issues] + before_action :set_webui_actions, only: %i[request_action request_action_changes] after_action :verify_authorized, only: [:create] @@ -157,11 +158,7 @@ def modify_review # TODO: Remove this once request_show_redesign is rolled out def request_action - @diff_limit = params[:full_diff] ? 0 : nil @index = params[:index].to_i - @actions = @bs_request.webui_actions(filelimit: @diff_limit, tarlimit: @diff_limit, diff_to_superseded: @diff_to_superseded, diffs: true, - action_id: params['id'].to_i, cacheonly: 1) - @action = @actions.find { |action| action[:id] == params['id'].to_i } @active = @action[:name] if @action[:diff_not_cached] @@ -176,13 +173,6 @@ def request_action end def request_action_changes - # TODO: Change @diff_limit to a local variable - @diff_limit = params[:full_diff] ? 0 : nil - # TODO: Change @actions to a local variable - @actions = @bs_request.webui_actions(filelimit: @diff_limit, tarlimit: @diff_limit, diff_to_superseded: @diff_to_superseded, diffs: true, - action_id: params['id'].to_i, cacheonly: 1) - @action = @actions.find { |action| action[:id] == params['id'].to_i } - cache_diff_data respond_to do |format| @@ -570,4 +560,15 @@ def set_influxdb_data_request_actions bs_request_action_type: @bs_request_action.class.name } end + + def set_webui_actions + diff_limit = params[:full_diff] ? 0 : nil + @actions = @bs_request.webui_actions(filelimit: diff_limit, + tarlimit: diff_limit, + diff_to_superseded: @diff_to_superseded, + diffs: true, + action_id: params['id'].to_i, + cacheonly: 1) + @action = @actions.find { |action| action[:id] == params['id'].to_i } + end end