diff --git a/app/services/form1010cg/auditor.rb b/app/services/form1010cg/auditor.rb index b71874848ab..f09cea1bd47 100644 --- a/app/services/form1010cg/auditor.rb +++ b/app/services/form1010cg/auditor.rb @@ -50,7 +50,6 @@ def record_submission_attempt increment self.class.metrics.submission.attempt end - # rubocop:disable Metrics/MethodLength def record_caregivers(claim) secondaries_count = 0 %w[one two].each do |attr| @@ -58,24 +57,11 @@ def record_caregivers(claim) end if claim.primary_caregiver_data.present? - case secondaries_count - when 0 - increment(self.class.metrics.submission.caregivers.primary_no_secondary) - when 1 - increment(self.class.metrics.submission.caregivers.primary_one_secondary) - when 2 - increment(self.class.metrics.submission.caregivers.primary_two_secondary) - end + increment_primary_caregiver_data(secondaries_count) else - case secondaries_count - when 1 - increment(self.class.metrics.submission.caregivers.no_primary_one_secondary) - when 2 - increment(self.class.metrics.submission.caregivers.no_primary_two_secondary) - end + increment_no_primary_caregiver_data(secondaries_count) end end - # rubocop:enable Metrics/MethodLength def record_submission_failure_client_data(errors:, claim_guid: nil) increment self.class.metrics.submission.failure.client.data @@ -108,6 +94,28 @@ def log_mpi_search_result(claim_guid:, form_subject:, result:) private + def increment_primary_caregiver_data(secondaries_count) + caregivers = self.class.metrics.submission.caregivers + case secondaries_count + when 0 + increment(caregivers.primary_no_secondary) + when 1 + increment(caregivers.primary_one_secondary) + when 2 + increment(caregivers.primary_two_secondary) + end + end + + def increment_no_primary_caregiver_data(secondaries_count) + caregivers = self.class.metrics.submission.caregivers + case secondaries_count + when 1 + increment(caregivers.no_primary_one_secondary) + when 2 + increment(caregivers.no_primary_two_secondary) + end + end + def increment(stat) StatsD.increment stat end diff --git a/app/sidekiq/central_mail/submit_central_form686c_job.rb b/app/sidekiq/central_mail/submit_central_form686c_job.rb index 312210af7e3..4330e3dd5ad 100644 --- a/app/sidekiq/central_mail/submit_central_form686c_job.rb +++ b/app/sidekiq/central_mail/submit_central_form686c_job.rb @@ -142,7 +142,6 @@ def to_faraday_upload(file_path) ) end - # rubocop:disable Metrics/MethodLength def process_pdf(pdf_path, timestamp = nil, form_id = nil) stamped_path1 = PDFUtilities::DatestampPdf.new(pdf_path).run(text: 'VA.GOV', x: 5, y: 5, timestamp:) stamped_path2 = PDFUtilities::DatestampPdf.new(stamped_path1).run( @@ -152,21 +151,11 @@ def process_pdf(pdf_path, timestamp = nil, form_id = nil) text_only: true ) if form_id.present? - PDFUtilities::DatestampPdf.new(stamped_path2).run( - text: 'Application Submitted on va.gov', - x: form_id == '686C-674' ? 400 : 300, - y: form_id == '686C-674' ? 675 : 775, - text_only: true, # passing as text only because we override how the date is stamped in this instance - timestamp:, - page_number: form_id == '686C-674' ? 6 : 0, - template: "lib/pdf_fill/forms/pdfs/#{form_id}.pdf", - multistamp: true - ) + stamped_pdf_with_form(form_id, stamped_path2, timestamp) else stamped_path2 end end - # rubocop:enable Metrics/MethodLength def get_hash_and_pages(file_path) { @@ -240,6 +229,19 @@ def send_confirmation_email(user) private + def stamped_pdf_with_form(form_id, path, timestamp) + PDFUtilities::DatestampPdf.new(path).run( + text: 'Application Submitted on va.gov', + x: form_id == '686C-674' ? 400 : 300, + y: form_id == '686C-674' ? 675 : 775, + text_only: true, # passing as text only because we override how the date is stamped in this instance + timestamp:, + page_number: form_id == '686C-674' ? 6 : 0, + template: "lib/pdf_fill/forms/pdfs/#{form_id}.pdf", + multistamp: true + ) + end + def log_cmp_response(response) log_message_to_sentry("vre-central-mail-response: #{response}", :info, {}, { team: 'vfs-ebenefits' }) end diff --git a/app/sidekiq/copay_notifications/mcp_notification_email_job.rb b/app/sidekiq/copay_notifications/mcp_notification_email_job.rb index 37243b7f34e..e61a4009ea1 100644 --- a/app/sidekiq/copay_notifications/mcp_notification_email_job.rb +++ b/app/sidekiq/copay_notifications/mcp_notification_email_job.rb @@ -14,13 +14,8 @@ class McpNotificationEmailJob include SentryLogging sidekiq_options retry: 14 - def perform(vet360_id, template_id, backup_email = nil, personalisation = nil) # rubocop:disable Metrics/MethodLength - person_resp = if Flipper.enabled?(:va_v3_contact_information_service) - VAProfile::V2::ContactInformation::Service.get_person(vet360_id) - else - VAProfile::ContactInformation::Service.get_person(vet360_id) - end - + def perform(vet360_id, template_id, backup_email = nil, personalisation = nil) + person_resp = person_response(vet360_id) email_address = person_resp.person&.emails&.first&.email_address || backup_email if email_address @@ -51,5 +46,15 @@ def send_email(email, template_id, personalisation) }.compact ) end + + private + + def person_response(vet360_id) + if Flipper.enabled?(:va_v3_contact_information_service) + VAProfile::V2::ContactInformation::Service.get_person(vet360_id) + else + VAProfile::ContactInformation::Service.get_person(vet360_id) + end + end end end diff --git a/app/sidekiq/cypress_viewport_updater/cypress_config_js_file.rb b/app/sidekiq/cypress_viewport_updater/cypress_config_js_file.rb index 05d9f72a955..3360310df6a 100644 --- a/app/sidekiq/cypress_viewport_updater/cypress_config_js_file.rb +++ b/app/sidekiq/cypress_viewport_updater/cypress_config_js_file.rb @@ -22,18 +22,20 @@ def initialize super(github_path: 'config/cypress.config.js', name: 'cypress.config.js') end - # rubocop:disable Metrics/MethodLength def update(viewports:) - viewport_type = nil - viewport_idx = nil - skip_next_line = false lines = raw_content.split("\n") + self.updated_content = "#{process_lines(lines, viewports)}\n" + self + end - self.updated_content = "#{lines.each_with_object([]).with_index do |(line, new_lines), idx| - if skip_next_line - skip_next_line = false - next - end + private + + def process_lines(lines, viewports) + viewport_type, viewport_idx = nil + skip_next_line = false + + lines.each_with_object([]).with_index do |(line, new_lines), idx| + next if skip_next_line.tap { skip_next_line = false } if (type = VIEWPORT_TYPES.keys.select { |t| line.include?(t.to_s) }.first) viewport_type = VIEWPORT_TYPES[type] @@ -46,42 +48,38 @@ def update(viewports:) rewrite_line(line:, new_value: viewports.desktop[0].height, prop: 'viewportHeight') elsif (prop = VIEWPORT_PROPS.select { |p| line.include?(p.to_s) }.first) viewport_idx += 1 if prop == 'height:' - if prop == 'devicesWithViewport:' && lines[idx + 1].exclude?('percentTraffic:') - skip_next_line = true - end - rewrite_line(line:, - new_value: viewports - .send(viewport_type)[prop == 'height:' ? viewport_idx - 1 : viewport_idx] - .send(prop.chomp(':')), - prop:) + skip_next_line = true if prop_with_viewport(prop) && line_excludes_traffic(lines, idx) + viewport_prop_new_line(viewports, line, prop, viewport_type, viewport_idx) end - new_lines.push(new_line.nil? ? line : new_line) - end.flatten.join("\n")}\n" - - self + end.flatten.join("\n") end - # rubocop:enable Metrics/MethodLength - private + def viewport_prop_new_line(viewports, line, prop, viewport_type, viewport_idx) + viewport_type_index = prop == 'height:' ? viewport_idx - 1 : viewport_idx + new_value = viewports.send(viewport_type)[viewport_type_index].send(prop.chomp(':')) + rewrite_line(line:, new_value:, prop:) + end def rewrite_line(line:, new_value:, prop:) - line_parts = line.split(':') + line_prefix = line.split(':')[0] + wrapped_value = WRAP_VALUE_IN_QUOTES.include?(prop) ? "'#{new_value}'" : new_value.to_s + new_line = "#{line_prefix}: #{wrapped_value}," + + return new_line if new_line.length <= 80 - new_line = if WRAP_VALUE_IN_QUOTES.include?(prop) - line_parts[0] + ": '#{new_value}'," - else - line_parts[0] + ": #{new_value}," - end + [ + "#{line_prefix}:", + "#{line_prefix.match(/^\s+/)[0]} #{wrapped_value}," + ] + end - if new_line.length > 80 - return [ - "#{line_parts[0]}:", - "#{line_parts[0].match(/^\s+/)[0]} #{new_line.split(': ')[1]}" - ] - end + def prop_with_viewport(prop) + prop == 'devicesWithViewport:' + end - new_line + def line_excludes_traffic(lines, idx) + lines[idx + 1].exclude?('percentTraffic:') end end end