From df45cce18d7c2271affdf0fa7f8d01b7710431e4 Mon Sep 17 00:00:00 2001 From: tooyosi Date: Thu, 15 Feb 2024 17:24:59 +0000 Subject: [PATCH] houndbot refactorings --- app/controllers/api/v1/project_preferences_controller.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/project_preferences_controller.rb b/app/controllers/api/v1/project_preferences_controller.rb index cf60f5c84..476548c96 100644 --- a/app/controllers/api/v1/project_preferences_controller.rb +++ b/app/controllers/api/v1/project_preferences_controller.rb @@ -36,16 +36,19 @@ def update_settings ) end - def find_upp + def fetch_upp_list if action_name == 'read_settings' @upp_list = UserProjectPreference.where(project_id: params[:project_id]).where.not(email_communication: nil) @upp_list = @upp_list.where(user_id: params[:user_id]) if params[:user_id].present? else @upp_list = UserProjectPreference.where(user_id: params_for[:user_id], project_id: params_for[:project_id]) end + end + def find_upp + fetch_upp_list @upp = @upp_list.first - raise ActiveRecord::RecordNotFound unless !@upp.blank? + raise ActiveRecord::RecordNotFound unless @upp.present? raise Api::Unauthorized, 'You must be the project owner or a collaborator' unless user_allowed? end