Skip to content

Commit

Permalink
Only add file list to overflow text if there are less than 41 files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
NB28VT committed Apr 25, 2024
1 parent 24c5d39 commit 8d1de24
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
37 changes: 26 additions & 11 deletions lib/evss/disability_compensation_form/data_translation_all_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)'

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

###
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8d1de24

Please sign in to comment.