Skip to content

Commit

Permalink
Merge branch 'master' into use-callback-with-emails-with-user-account
Browse files Browse the repository at this point in the history
  • Loading branch information
Thrillberg authored Nov 27, 2024
2 parents aa88912 + e1e0a43 commit aca2ee1
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 105 deletions.
18 changes: 18 additions & 0 deletions app/controllers/v0/disability_compensation_forms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def suggested_conditions
end

def submit_all_claim
temp_separation_location_fix if Flipper.enabled?(:disability_compensation_temp_separation_location_code_string,
@current_user)

saved_claim = SavedClaim::DisabilityCompensation::Form526AllClaim.from_hash(form_content)
saved_claim.save ? log_success(saved_claim) : log_failure(saved_claim)
submission = create_submission(saved_claim)
Expand Down Expand Up @@ -172,5 +175,20 @@ def missing_disabilities?(submission)
end
false
end

# TEMPORARY
# Turn separation location into string
# 11/18/2024 BRD EVSS -> Lighthouse migration caused separation location to turn into an integer,
# while SavedClaim (vets-json-schema) is expecting a string
def temp_separation_location_fix
if form_content.is_a?(Hash) && form_content['form526'].is_a?(Hash)
separation_location_code = form_content.dig('form526', 'serviceInformation', 'separationLocation')
unless separation_location_code.nil?
form_content['form526']['serviceInformation']['separationLocation']['separationLocationCode'] =
separation_location_code.to_s
end
end
end
# END TEMPORARY
end
end
10 changes: 7 additions & 3 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ features:
actor_type: user
description: Enables the endpoints of the accredited representative portal
enable_in_development: true
aedp_vadx:
actor_type: user
description: Enables the VADX experimental features in the AEDP application
enable_in_development: true
all_claims_add_disabilities_enhancement:
actor_type: user
description: Enables enhancement to the 21-526EZ "Add Disabilities" page being implemented by the Conditions Team.
Expand Down Expand Up @@ -166,9 +170,6 @@ features:
champva_unique_temp_file_names:
actor_type: user
description: Enables unique temp file names for CHAMPVA PDF files
champva_file_recreate:
actor_type: user
description: Enhances file creation reliability by adding retry functionality in the vets-api tmp folder
champva_failure_email_job_enabled:
actor_type: user
description: Enables sending failure notification emails for IVC CHAMPVA form submissions that lack a Pega status
Expand Down Expand Up @@ -530,6 +531,9 @@ features:
actor_type: user
description: enables sending flashes to BGS for disability_compensation submissions.
enable_in_development: true
disability_compensation_temp_separation_location_code_string:
actor_type: user
description: enables forcing separation location code to be a string in submit_all_claim endpoint.
disability_compensation_form4142_supplemental:
actor_type: user
description: Use Lighthouse API to submit supplemental Form 21-4142 from Form 526EZ submissions
Expand Down
48 changes: 48 additions & 0 deletions config/settings/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,51 @@ google_analytics_cvu:
type: service_account
hca:
ca: []
lighthouse:
benefits_intake:
path: /services/vba_documents
use_mocks: false
version: v1
veteran_verification:
form526:
use_mocks: false
maintenance:
services:
bgs: P5Q2OCZ
modules_appeals_api:
legacy_appeals_enabled: true
schema_dir: config/schemas
mvi:
pii_logging: false
session_cookie:
secure: true
sidekiq_admin_panel: false
sidekiq:
github_organization: department-of-veterans-affairs
va_profile:
contact_information:
cache_enabled: true
enabled: true
mock: false
timeout: 30
demographics:
cache_enabled: false
enabled: true
mock: false
timeout: 30
military_personnel:
cache_enabled: false
enabled: true
mock: false
timeout: 30
veteran_status:
mock: false
vba_documents:
enable_validate_document_endpoint: true
s3:
enabled: true
slack:
daily_notification_hour: 7
in_flight_notification_hung_time_in_days: 14
renotification_in_minutes: 1440
update_stalled_notification_in_minutes: 180
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class SeparationLocation
include ActiveModel::Serialization
include Virtus.model

attribute :code, Integer
attribute :code, String
attribute :description, String
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,50 +15,25 @@ class UploadsController < ApplicationController
'10-7959A' => 'vha_10_7959a'
}.freeze

if Flipper.enabled?(:champva_file_recreate, @user)
def submit
Datadog::Tracing.trace('Start IVC File Submission') do
form_id = get_form_id
Datadog::Tracing.active_trace&.set_tag('form_id', form_id)
parsed_form_data = JSON.parse(params.to_json)
statuses, error_message = handle_file_uploads(form_id, parsed_form_data)
def submit
Datadog::Tracing.trace('Start IVC File Submission') do
form_id = get_form_id
Datadog::Tracing.active_trace&.set_tag('form_id', form_id)
parsed_form_data = JSON.parse(params.to_json)
statuses, error_message = handle_file_uploads(form_id, parsed_form_data)

response = build_json(Array(statuses), error_message)
response = build_json(Array(statuses), error_message)

if @current_user && response[:status] == 200
InProgressForm.form_for_user(params[:form_number], @current_user)&.destroy!
end

render json: response[:json], status: response[:status]
end
rescue => e
Rails.logger.error "Error: #{e.message}"
Rails.logger.error e.backtrace.join("\n")
render json: { error_message: "Error: #{e.message}" }, status: :internal_server_error
end
else
def submit
Datadog::Tracing.trace('Start IVC File Submission') do
form_id = get_form_id
Datadog::Tracing.active_trace&.set_tag('form_id', form_id)
parsed_form_data = JSON.parse(params.to_json)
file_paths, metadata = get_file_paths_and_metadata(parsed_form_data)
statuses, error_message = FileUploader.new(form_id, metadata, file_paths, true).handle_uploads
response = build_json(Array(statuses), error_message)

if @current_user && response[:status] == 200
InProgressForm.form_for_user(params[:form_number],
@current_user)&.destroy!
end

render json: response[:json], status: response[:status]
rescue => e
Rails.logger.error "Error: #{e.message}"
Rails.logger.error e.backtrace.join("\n")
render json: { error_message: "Error: #{e.message}" },
status: :internal_server_error
if @current_user && response[:status] == 200
InProgressForm.form_for_user(params[:form_number], @current_user)&.destroy!
end

render json: response[:json], status: response[:status]
end
rescue => e
Rails.logger.error "Error: #{e.message}"
Rails.logger.error e.backtrace.join("\n")
render json: { error_message: "Error: #{e.message}" }, status: :internal_server_error
end

def submit_supporting_documents
Expand All @@ -74,22 +49,20 @@ def submit_supporting_documents

private

if Flipper.enabled?(:champva_file_recreate, @user)
def handle_file_uploads(form_id, parsed_form_data)
def handle_file_uploads(form_id, parsed_form_data)
file_paths, metadata = get_file_paths_and_metadata(parsed_form_data)
statuses, error_message = FileUploader.new(form_id, metadata, file_paths, true).handle_uploads
statuses = Array(statuses)

# Retry attempt if specific error message is found
if statuses.any? do |status|
status.is_a?(String) && status.include?('No such file or directory @ rb_sysopen')
end
file_paths, metadata = get_file_paths_and_metadata(parsed_form_data)
statuses, error_message = FileUploader.new(form_id, metadata, file_paths, true).handle_uploads
statuses = Array(statuses)

# Retry attempt if specific error message is found
if statuses.any? do |status|
status.is_a?(String) && status.include?('No such file or directory @ rb_sysopen')
end
file_paths, metadata = get_file_paths_and_metadata(parsed_form_data)
statuses, error_message = FileUploader.new(form_id, metadata, file_paths, true).handle_uploads
end

[statuses, error_message]
end

[statuses, error_message]
end

def get_attachment_ids_and_form(parsed_form_data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,64 +186,62 @@
end
end

if Flipper.enabled?(:champva_file_recreate, @user)
describe '#handle_file_uploads' do
let(:controller) { IvcChampva::V1::UploadsController.new }

forms.each do |form_file|
form_id = form_file.gsub('vha_', '').gsub('.json', '').upcase
form_numbers_and_classes[form_id]

context "with form #{form_id}" do
let(:form_id) { form_id }
let(:parsed_form_data) do
JSON.parse(Rails.root.join('modules', 'ivc_champva', 'spec', 'fixtures', 'form_json', form_file).read)
end
let(:file_paths) { ['/path/to/file1.pdf', '/path/to/file2.pdf'] }
let(:metadata) { { 'attachment_ids' => %w[id1 id2] } }
let(:file_uploader) { instance_double(IvcChampva::FileUploader) }
describe '#handle_file_uploads' do
let(:controller) { IvcChampva::V1::UploadsController.new }

forms.each do |form_file|
form_id = form_file.gsub('vha_', '').gsub('.json', '').upcase
form_numbers_and_classes[form_id]

context "with form #{form_id}" do
let(:form_id) { form_id }
let(:parsed_form_data) do
JSON.parse(Rails.root.join('modules', 'ivc_champva', 'spec', 'fixtures', 'form_json', form_file).read)
end
let(:file_paths) { ['/path/to/file1.pdf', '/path/to/file2.pdf'] }
let(:metadata) { { 'attachment_ids' => %w[id1 id2] } }
let(:file_uploader) { instance_double(IvcChampva::FileUploader) }

before do
allow(controller).to receive(:get_file_paths_and_metadata).and_return([file_paths, metadata])
allow(IvcChampva::FileUploader).to receive(:new).and_return(file_uploader)
end

context 'when file uploads succeed' do
before do
allow(controller).to receive(:get_file_paths_and_metadata).and_return([file_paths, metadata])
allow(IvcChampva::FileUploader).to receive(:new).and_return(file_uploader)
allow(file_uploader).to receive(:handle_uploads).and_return([[200], nil])
end

context 'when file uploads succeed' do
before do
allow(file_uploader).to receive(:handle_uploads).and_return([[200], nil])
end
it 'returns success statuses and no error message' do
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([200])
expect(error_message).to be_nil
end
end

it 'returns success statuses and no error message' do
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([200])
expect(error_message).to be_nil
end
context 'when file uploads fail with specific error message' do
before do
allow(file_uploader).to receive(:handle_uploads).and_return([['No such file or directory @ rb_sysopen'],
'File not found'])
end

context 'when file uploads fail with specific error message' do
before do
allow(file_uploader).to receive(:handle_uploads).and_return([['No such file or directory @ rb_sysopen'],
'File not found'])
end

it 'retries the file uploads and returns the final statuses and error message' do
allow(file_uploader).to receive(:handle_uploads).and_return([[200], nil])
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([200])
expect(error_message).to be_nil
end
it 'retries the file uploads and returns the final statuses and error message' do
allow(file_uploader).to receive(:handle_uploads).and_return([[200], nil])
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([200])
expect(error_message).to be_nil
end
end

context 'when file uploads fail with other errors' do
before do
allow(file_uploader).to receive(:handle_uploads).and_return([[400], 'Upload failed'])
end
context 'when file uploads fail with other errors' do
before do
allow(file_uploader).to receive(:handle_uploads).and_return([[400], 'Upload failed'])
end

it 'returns the error statuses and error message' do
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([400])
expect(error_message).to eq('Upload failed')
end
it 'returns the error statuses and error message' do
statuses, error_message = controller.send(:handle_file_uploads, form_id, parsed_form_data)
expect(statuses).to eq([400])
expect(error_message).to eq('Upload failed')
end
end
end
Expand Down

0 comments on commit aca2ee1

Please sign in to comment.