Skip to content

Commit

Permalink
Refactor action related code
Browse files Browse the repository at this point in the history
  • Loading branch information
danidoni committed Mar 15, 2024
1 parent c2d6a5b commit cc452b4
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/api/app/controllers/webui/request_controller.rb
Expand Up @@ -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]

Expand Down Expand Up @@ -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]
Expand All @@ -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|
Expand Down Expand Up @@ -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

0 comments on commit cc452b4

Please sign in to comment.