diff --git a/app/helpers/sync_decided_appeals_helper.rb b/app/helpers/sync_decided_appeals_helper.rb index 45adcc0e36e..01ffdc3c372 100644 --- a/app/helpers/sync_decided_appeals_helper.rb +++ b/app/helpers/sync_decided_appeals_helper.rb @@ -15,17 +15,17 @@ def sync_decided_appeals .pluck(:id, :vacols_id) appeal_state_ids_hash = appeal_state_ids.to_h - vacols_decision_dates = get_decision_dates(appeal_state_ids_hash.values).to_h ActiveSupport::Dependencies.interlock.permit_concurrent_loads do Parallel.each(appeal_state_ids_hash, in_threads: 4) do |appeal_state_hash| - appeal_state_id = appeal_state_hash[0] - vacols_id = appeal_state_hash[1] - # If there is a decision date on the VACOLS record, - # update the decision_mailed status on the AppealState to true - if vacols_decision_dates[vacols_id].present? - AppealState.find(appeal_state_id).decision_mailed_appeal_state_update_action! + Rails.application.executor.wrap do + appeal_state_id, vacols_id = appeal_state_hash + # If there is a decision date on the VACOLS record, + # update the decision_mailed status on the AppealState to true + if vacols_decision_dates[vacols_id].present? + AppealState.find(appeal_state_id).decision_mailed_appeal_state_update_action! + end end end end diff --git a/spec/services/sqs_service_spec.rb b/spec/services/sqs_service_spec.rb index 9322989ff54..e13a9ccdf5d 100644 --- a/spec/services/sqs_service_spec.rb +++ b/spec/services/sqs_service_spec.rb @@ -2,6 +2,7 @@ describe SqsService do let(:sqs_client) { SqsService.sqs_client } + let(:test_queue_prefix) { "sqs_service_test_" } before(:each) { wipe_queues } after(:all) { wipe_queues } @@ -13,15 +14,15 @@ context "FIFO" do let(:fifo) { true } - let(:queue_name) { "my_fifo_queue" } + let(:queue_name) { "#{test_queue_prefix}my_fifo_queue" } it "the queue is found and is validated to be a FIFO queue" do expect(subject { SqsService.find_queue_url_by_name(name: queue_name, check_fifo: true) }) - .to include("caseflow_test_my_fifo_queue.fifo") + .to include("sqs_service_test_my_fifo_queue.fifo") end it "the queue is found while validation is opted out" do - is_expected.to include("caseflow_test_my_fifo_queue.fifo") + is_expected.to include("sqs_service_test_my_fifo_queue.fifo") end it "a non-existent queue cannot be found" do @@ -34,17 +35,17 @@ context "non-FIFO" do let(:fifo) { false } - let(:queue_name) { "my_normal_queue" } + let(:queue_name) { "#{test_queue_prefix}my_normal_queue" } it "the queue is found" do - is_expected.to include("caseflow_test_my_normal_queue") + is_expected.to include("sqs_service_test_my_normal_queue") is_expected.to_not include(".fifo") end it "the queue found fails the FIFO check" do expect { SqsService.find_queue_url_by_name(name: queue_name, check_fifo: true) }.to raise_error do |error| expect(error).to be_a(Caseflow::Error::SqsUnexpectedQueueTypeError) - expect(error.to_s).to include("No FIFO queue with name my_normal_queue could be located.") + expect(error.to_s).to include("No FIFO queue with name #{test_queue_prefix}my_normal_queue could be located.") end end end @@ -97,7 +98,7 @@ def create_queue(name, fifo = false) sqs_client.create_queue({ - queue_name: "caseflow_test_#{name}#{fifo ? '.fifo' : ''}".to_sym, + queue_name: "#{name}#{fifo ? '.fifo' : ''}".to_sym, attributes: fifo ? { "FifoQueue" => "true" } : {} }) end @@ -127,7 +128,7 @@ def approximate_number_of_messages_in_queue(queue_url) def wipe_queues client = SqsService.sqs_client - queues_to_delete = client.list_queues.queue_urls.filter { _1.include?("caseflow_test") } + queues_to_delete = client.list_queues.queue_urls.filter { _1.include?("sqs_service_spec") } queues_to_delete.each do |queue_url| client.delete_queue(queue_url: queue_url)