From 8d1de2462c7568279f75b0b12bf1e77878c2ac1e Mon Sep 17 00:00:00 2001 From: Nathan Burgess Date: Thu, 25 Apr 2024 17:24:20 -0400 Subject: [PATCH] Only add file list to overflow text if there are less than 41 files Tweaks the file list logic to only display a list of files if there are less than 41, otherwise just lists how many files there are. This is to avoid adding too many pages to the overflow. 40 is an educated guess of how many files we would want to list at most, we will be following up to come up with a better figure based on historical data --- .../data_translation_all_claim.rb | 37 +++++++++++++------ .../data_translation_all_claim_spec.rb | 35 +++++++++++++++--- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/lib/evss/disability_compensation_form/data_translation_all_claim.rb b/lib/evss/disability_compensation_form/data_translation_all_claim.rb index 61a42a2be90..887f8ea1ef8 100644 --- a/lib/evss/disability_compensation_form/data_translation_all_claim.rb +++ b/lib/evss/disability_compensation_form/data_translation_all_claim.rb @@ -32,6 +32,11 @@ class DataTranslationAllClaim # rubocop:disable Metrics/ClassLength 'PMR contractor for processing in accordance with M21-1 III.iii.1.D.2.' FORM0781_OVERFLOW_TEXT = "VA Form 0781/a has been completed by the applicant and sent to the VBMS eFolder\n" + # If the veteran submitted supplemental attachments for this claim, + # we list them in the form overflowText for the claim adjudicator to cross reference with the eFolder + # However, if the file list is long enough we don't want to take up too much space in the overflow text + MAX_VETERAN_UPLOADED_FILE_LIST_ATTACHMENTS = 40 + # EVSS validates this date using CST, at some point this may change to EST. EVSS_TZ = 'Central Time (US & Canada)' @@ -99,19 +104,29 @@ def overflow_text end def attached_files_list - file_guids = input_form['attachments']&.pluck('confirmationCode') - - if file_guids&.length - attachments = SupportingEvidenceAttachment.where(guid: file_guids) - list = "The veteran uploaded #{attachments.count} documents along with this claim. " \ - "Please verify in VBMS eFolder:\n" - filenames = attachments.map(&:original_filename).sort - filenames.each { |filename| list += "#{filename}\n" } - - return list + list = '' + attachments = input_form['attachments'] + + if attachments&.length + if attachments.length <= MAX_VETERAN_UPLOADED_FILE_LIST_ATTACHMENTS + list += "The veteran uploaded #{attachments.length} documents along with this claim. " \ + "Please verify in VBMS eFolder:\n" + + file_guids = attachments&.pluck('confirmationCode') + attachment_files = SupportingEvidenceAttachment.where(guid: file_guids) + filenames = attachment_files.map(&:original_filename).sort + + filenames.each { |filename| list += "#{filename}\n" } + else + # If the file list is too long, we only include the message + # This is to avoid overfilling the overflowText field + # We also don't end the instruction with a colon because we aren't listing filenames after it + list += "The veteran uploaded #{attachments.length} documents along with this claim. " \ + "Please verify in VBMS eFolder\n" + end end - '' + list end ### diff --git a/spec/lib/evss/disability_compensation_form/data_translation_all_claim_spec.rb b/spec/lib/evss/disability_compensation_form/data_translation_all_claim_spec.rb index 300c44f70c6..cb15c9ee8b7 100644 --- a/spec/lib/evss/disability_compensation_form/data_translation_all_claim_spec.rb +++ b/spec/lib/evss/disability_compensation_form/data_translation_all_claim_spec.rb @@ -185,12 +185,35 @@ Flipper.enable(:form526_include_document_upload_list_in_overflow_text) end - it 'includes a list of documents in the overflow text ordered alphabetically' do - expected_file_list = 'The veteran uploaded 2 documents along with this claim. ' \ - "Please verify in VBMS eFolder:\n" \ - "my_file_1.pdf\n" \ - "my_file_2.pdf\n" - expect(subject.send(:overflow_text)).to eq(expected_file_list) + context 'when there is less than 40 files present' do + it 'includes a list of documents in the overflow text ordered alphabetically' do + expected_file_list = 'The veteran uploaded 2 documents along with this claim. ' \ + "Please verify in VBMS eFolder:\n" \ + "my_file_1.pdf\n" \ + "my_file_2.pdf\n" + expect(subject.send(:overflow_text)).to eq(expected_file_list) + end + end + + context 'when there are more than 40 files present' do + it 'includes the document count but does not list the file names' do + attachments = [] + + 41.times do + attachments << { 'confirmationCode' => SecureRandom.uuid } + end + + form_content = { + 'form526' => { + 'attachments' => attachments + } + } + + subject = described_class.new(user, form_content, false) + expect(subject.send(:overflow_text)).to eq( + "The veteran uploaded 41 documents along with this claim. Please verify in VBMS eFolder\n" + ) + end end end