diff --git a/.rubocop.yml b/.rubocop.yml index 807abfd74e7..0b80952c8c7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -99,26 +99,34 @@ Metrics/MethodLength: Exclude: - app/jobs/middleware/job_sentry_scope_middleware.rb - app/jobs/fetch_all_active_ama_appeals_job.rb + - lib/helpers/unrecognized_appellant.rb + - lib/helpers/duplicate_veteran_checker.rb + - lib/helpers/report_load_end_product_sync.rb + - lib/helpers/claim_label_change.rb - "spec/**/*" Metrics/ClassLength: Max: 400 + Exclude: + - lib/helpers/duplicate_veteran_checker.rb Metrics/AbcSize: Max: 30 Exclude: - app/jobs/virtual_hearings/create_conference_job.rb - app/jobs/fetch_all_active_ama_appeals_job.rb + - lib/helpers/duplicate_veteran_checker.rb Metrics/CyclomaticComplexity: Exclude: - app/services/virtual_hearings/resend_virtual_hearing_emails_service.rb - app/jobs/fetch_all_active_ama_appeals_job.rb + - lib/helpers/duplicate_veteran_checker.rb Metrics/PerceivedComplexity: Exclude: - app/jobs/fetch_all_active_ama_appeals_job.rb - + - lib/helpers/duplicate_veteran_checker.rb Style/DoubleNegation: Enabled: false @@ -160,6 +168,21 @@ Style/FormatStringToken: Enabled: true EnforcedStyle: annotated +Style/HashEachMethods: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: true + +Style/ExponentialNotation: + Enabled: true + +Style/SlicingWithRange: + Enabled: true + Naming/FileName: Enabled: false @@ -180,8 +203,24 @@ Lint/UnusedMethodArgument: Exclude: - 'lib/fakes/*.rb' +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + Layout/LineLength: Max: 120 + Exclude: + - lib/helpers/duplicate_veteran_checker.rb + - lib/helpers/report_load_end_product_sync.rb + Layout/MultilineMethodCallIndentation: EnforcedStyle: indented + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true + +Layout/SpaceAroundMethodCallOperator: + Enabled: true diff --git a/Gemfile b/Gemfile index 02511aa1b49..f3ffe697c16 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -# rubocop:disable Metrics/LineLength +# rubocop:disable Layout/LineLength source ENV["GEM_SERVER_URL"] || "https://rubygems.org" # State machine @@ -116,7 +116,7 @@ group :test, :development, :demo do gem "rspec-rails" # For CircleCI test metadata analysis gem "rspec_junit_formatter" - gem "rubocop", "= 0.79", require: false + gem "rubocop", "= 0.83", require: false gem "rubocop-performance" gem "rubocop-rails" gem "scss_lint", require: false @@ -145,11 +145,11 @@ end group :test do gem "knapsack_pro", "~> 3.8" + gem "rspec-github", require: false # For retrying failed feature tests. Read more: https://github.com/NoRedInk/rspec-retry gem "rspec-retry" gem "webmock" - gem "rspec-github", require: false end -# rubocop:enable Metrics/LineLength +# rubocop:enable Layout/LineLength gem "json_schemer", "~> 0.2.16" diff --git a/Gemfile.lock b/Gemfile.lock index e44d55592b8..4299a55279a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -143,7 +143,7 @@ GEM activerecord (>= 4.2.0) anbt-sql-formatter (0.1.0) arel (9.0.0) - ast (2.4.0) + ast (2.4.2) aws-sdk (2.10.112) aws-sdk-resources (= 2.10.112) aws-sdk-core (2.10.112) @@ -348,7 +348,7 @@ GEM ice_cube (0.16.3) immigrant (0.3.6) activerecord (>= 3.0) - jaro_winkler (1.5.4) + jaro_winkler (1.5.6) jmespath (1.3.1) jquery-rails (4.5.1) rails-dom-testing (>= 1, < 3) @@ -454,11 +454,11 @@ GEM paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.19.1) + parallel (1.23.0) paranoia (2.4.2) activerecord (>= 4.0, < 6.1) - parser (2.7.0.5) - ast (~> 2.4.0) + parser (2.7.2.0) + ast (~> 2.4.1) pdf-forms (1.2.0) cliver (~> 0.3.2) safe_shell (>= 1.0.3, < 2.0) @@ -513,7 +513,7 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) + rainbow (3.1.1) rake (12.3.3) rb-fsevent (0.10.3) rb-inotify (0.10.0) @@ -555,7 +555,7 @@ GEM rack (>= 1.4) reverse_markdown (1.4.0) nokogiri - rexml (3.2.5) + rexml (3.2.6) roo (2.8.2) nokogiri (~> 1) rubyzip (>= 1.2.1, < 2.0.0) @@ -586,13 +586,13 @@ GEM rspec-support (3.9.2) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.79.0) - jaro_winkler (~> 1.5.1) + rubocop (0.83.0) parallel (~> 1.10) parser (>= 2.7.0.1) rainbow (>= 2.2.2, < 4.0) + rexml ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) rubocop-performance (1.5.2) rubocop (>= 0.71.0) rubocop-rails (2.5.0) @@ -605,7 +605,7 @@ GEM ruby-oci8 (2.2.7) ruby-plsql (0.7.1) ruby-prof (1.4.1) - ruby-progressbar (1.10.1) + ruby-progressbar (1.13.0) ruby_dep (1.5.0) ruby_parser (3.20.3) sexp_processor (~> 4.16) @@ -691,7 +691,7 @@ GEM thread_safe (~> 0.1) uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.6.1) + unicode-display_width (1.8.0) unicode_utils (1.4.0) uniform_notifier (1.12.1) uri_template (0.7.0) @@ -809,7 +809,7 @@ DEPENDENCIES rspec-rails rspec-retry rspec_junit_formatter - rubocop (= 0.79) + rubocop (= 0.83) rubocop-performance rubocop-rails ruby-debug-ide diff --git a/app/controllers/appeals_controller.rb b/app/controllers/appeals_controller.rb index 4685e39f5d1..609ad735de4 100644 --- a/app/controllers/appeals_controller.rb +++ b/app/controllers/appeals_controller.rb @@ -49,6 +49,7 @@ def show_case_list end end + # rubocop:disable Metrics/MethodLength, Metrics/AbcSize def fetch_notification_list appeals_id = params[:appeals_id] respond_to do |format| @@ -63,9 +64,10 @@ def fetch_notification_list begin if !appeal.nil? pdf = PdfExportService.create_and_save_pdf("notification_report_pdf_template", appeal) - send_data pdf, filename: "Notification Report " + appeals_id + " " + date + ".pdf", type: "application/pdf", disposition: :attachment + pdf_file_name = "Notification Report " + appeals_id + " " + date + ".pdf" + send_data pdf, filename: pdf_file_name, type: "application/pdf", disposition: :attachment else - raise ActionController::RoutingError.new('Appeal Not Found') + fail ActionController::RoutingError, "Appeal Not Found" end rescue StandardError => error uuid = SecureRandom.uuid @@ -75,13 +77,14 @@ def fetch_notification_list end end format.csv do - raise ActionController::ParameterMissing.new('Bad Format') + fail ActionController::ParameterMissing, "Bad Format" end format.html do - raise ActionController::ParameterMissing.new('Bad Format') + fail ActionController::ParameterMissing, "Bad Format" end end end + # rubocop:enable Metrics/MethodLength, Metrics/AbcSize def document_count doc_count = EFolderService.document_count(appeal.veteran_file_number, current_user) @@ -291,13 +294,15 @@ def send_initial_notification_letter when "direct_review" parent_task = @appeal.tasks.find_by(type: "DistributionTask") end - @send_initial_notification_letter ||= @appeal.tasks.open.find_by(type: :SendInitialNotificationLetterTask) || - SendInitialNotificationLetterTask.create!( - appeal: @appeal, - parent: parent_task, - assigned_to: Organization.find_by_url("clerk-of-the-board"), - assigned_by: RequestStore[:current_user] - ) unless parent_task.nil? + unless parent_task.nil? + @send_initial_notification_letter ||= @appeal.tasks.open.find_by(type: :SendInitialNotificationLetterTask) || + SendInitialNotificationLetterTask.create!( + appeal: @appeal, + parent: parent_task, + assigned_to: Organization.find_by_url("clerk-of-the-board"), + assigned_by: RequestStore[:current_user] + ) + end end def power_of_attorney_data @@ -320,9 +325,15 @@ def find_notifications_by_appeals_id(appeals_id) # Retrieve notifications based on appeals_id, excluding statuses of 'No participant_id' & 'No claimant' @all_notifications = Notification.where(appeals_id: appeals_id) @allowed_notifications = @all_notifications.where(email_notification_status: nil) - .or(@all_notifications.where.not(email_notification_status: ["No Participant Id Found", "No Claimant Found", "No External Id"])) + .or(@all_notifications.where.not( + email_notification_status: ["No Participant Id Found", "No Claimant Found", "No External Id"] + )) .merge(@all_notifications.where(sms_notification_status: nil) - .or(@all_notifications.where.not(sms_notification_status: ["No Participant Id Found", "No Claimant Found", "No External Id"]))) + .or(@all_notifications.where.not(sms_notification_status: [ + "No Participant Id Found", + "No Claimant Found", + "No External Id" + ]))) # If no notifications were found, return an empty array, else return serialized notifications if @allowed_notifications == [] [] diff --git a/app/jobs/fetch_all_active_ama_appeals_job.rb b/app/jobs/fetch_all_active_ama_appeals_job.rb index 4da32ba508f..c31b27ccd49 100644 --- a/app/jobs/fetch_all_active_ama_appeals_job.rb +++ b/app/jobs/fetch_all_active_ama_appeals_job.rb @@ -200,7 +200,7 @@ def map_appeal_privacy_act_state(appeal) # Params: Appeal object # Returns: Hash of "hearing scheduled" key value pair def map_appeal_hearing_scheduled_state(appeal) - if (appeal&.hearings&.count&.> 0) && appeal.hearings.max_by(&:id).disposition.nil? + if (appeal&.hearings&.count > 0) && appeal.hearings.max_by(&:id).disposition.nil? return { hearing_scheduled: true } end diff --git a/app/jobs/quarterly_metrics_report_job.rb b/app/jobs/quarterly_metrics_report_job.rb index 226ce2c2595..7e92773b161 100644 --- a/app/jobs/quarterly_metrics_report_job.rb +++ b/app/jobs/quarterly_metrics_report_job.rb @@ -14,7 +14,6 @@ def perform private - # rubocop:disable Metrics/LineLength def additional_metrics hearings_show_rate = Metrics::HearingsShowRate.new(Metrics::DateRange.new(start_date, end_date)) ep_creation_rate = Metrics::NonDenialDecisions.new(Metrics::DateRange.new(start_date, end_date)) @@ -25,5 +24,4 @@ def additional_metrics "Mean time to recovery: See the 'Quarterly OIT Report' tab of the 'Caseflow Incident Stats' Google Sheet (https://docs.google.com/spreadsheets/d/1OAx_eRhwTaEM9aMx7eGg4KMR3Jgx5wYvsVBypHsZq5Q/edit#gid=593310513)" ] end - # rubocop:enable Metrics/LineLength end diff --git a/app/jobs/recurring_metrics_report_job.rb b/app/jobs/recurring_metrics_report_job.rb index 2ccd1052b5c..15283d36d89 100644 --- a/app/jobs/recurring_metrics_report_job.rb +++ b/app/jobs/recurring_metrics_report_job.rb @@ -35,7 +35,7 @@ def additional_metrics [] end - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength def build_report(appeals, async_stats, certification_metric) certification_paperless_metric = certification_metric.call[:paperless_metric] sc_stats = async_stats.stats[:supplemental_claims] @@ -53,5 +53,5 @@ def build_report(appeals, async_stats, certification_metric) report << async_stats.as_csv report.join("\n") end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength end diff --git a/app/models/legacy_appeal.rb b/app/models/legacy_appeal.rb index 6c83e717938..fad41be2c27 100644 --- a/app/models/legacy_appeal.rb +++ b/app/models/legacy_appeal.rb @@ -112,7 +112,7 @@ class UnknownLocationError < StandardError; end end # Note: If any of the names here are changed, they must also be changed in SpecialIssues.js 'specialIssue` value - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength SPECIAL_ISSUES = { contaminated_water_at_camp_lejeune: "Contaminated Water at Camp LeJeune", dic_death_or_accrued_benefits_united_states: "DIC - death, or accrued benefits - United States", @@ -140,7 +140,7 @@ class UnknownLocationError < StandardError; end vocational_rehab: "Vocational Rehabilitation and Employment", waiver_of_overpayment: "Waiver of Overpayment" }.freeze - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength # Codes for Appeals Status API TYPE_CODES = { diff --git a/app/models/vacols/case_issue.rb b/app/models/vacols/case_issue.rb index 1feaf5144e7..f4a54243233 100644 --- a/app/models/vacols/case_issue.rb +++ b/app/models/vacols/case_issue.rb @@ -31,7 +31,7 @@ def attributes_for_readjudication } end - # rubocop:disable MethodLength + # rubocop:disable Metrics/MethodLength # Issues can be labeled by looking up the combination of ISSPROG, # ISSCODE, ISSLEV1, ISSLEV2, and ISSLEV3 in the ISSREF table. @@ -109,7 +109,7 @@ def self.descriptions(vacols_ids) memo end end - # rubocop:enable MethodLength + # rubocop:enable Metrics/MethodLength def self.create_issue!(issue_attrs) create!(issue_attrs.merge(issseq: generate_sequence_id(issue_attrs[:isskey]))) diff --git a/lib/helpers/claim_label_change.rb b/lib/helpers/claim_label_change.rb index 0583ac7c36b..6f3f535a303 100644 --- a/lib/helpers/claim_label_change.rb +++ b/lib/helpers/claim_label_change.rb @@ -1,110 +1,104 @@ # frozen_string_literal: true module WarRoom - class ClaimLabelChange - def update_vbms(epe, original_code, new_code) - # An End Product Update is created with the desired changes. - ep_update = EndProductUpdate.create!( - end_product_establishment: epe, - original_decision_review: epe.source, - original_code: original_code, - new_code: new_code, - user: User.system_user - ) - - # Perform the End Product Update. Note the return message. - ep_update.perform! - - # print the End Product Update to confirm the results. - pp ep_update - - end - - def claim_code_check(code) - # Declare hash - codes_hash =[] - - #File open and process. - File.open('lib/helpers/END_PRODUCT_CODES.json') do |f| - codes_hash = JSON.parse(f.read) - end - - #if claim code is in hash return true, else false. - return codes_hash.has_key?(code) - end - - def same_claim_type(old_code, new_code) - # Checks the sameness of the first two chacters as a substing - if(old_code[0,2] == new_code[0,2]) - return true - else - return false - end - end - - - def update_caseflow(epe, new_code) - # Update the End Product in Caseflow. - epe.update(code: new_code) - - # Save the changes to the End Product. - epe.save - end - - def claim_label_updater(reference_id, original_code, new_code) - - #The End products must be of the same type. (030, 040, 070) - if (same_claim_type(original_code, new_code) == false) - puts("This is a different End Product, cannot claim label change. Aborting...") - fail Interrupt - end - - #Check that the new claim code is valid - if (claim_code_check(new_code) == false) - puts("Invalid new claim label code. Aborting...") - fail Interrupt - end - - #Check that the old claim code is valid for record - if (claim_code_check(original_code) == false) - puts("Invalid orginal claim label code. Aborting...") - fail Interrupt - end - - #set the user - RequestStore[:current_user] = WarRoom.user - - #find the End Product by claim ID - epe = EndProductEstablishment.find_by(reference_id: reference_id) - - #validate EPE exists. - if epe.nil? - puts("Unable to find EPE for that reference id. Aborting...") - fail Interrupt - end - - #check the EPE by printing to console. - pp epe - - #check caseflow - if(epe.code != new_code) - update_caseflow(epe, new_code) - end - - #check VBMS - bgs = BGSService.new.client.claims - #fetch Claim details from VBMS by Claim_ID - claim_detail = bgs.find_claim_detail_by_id(epe.reference_id) - #retrieve specific record - record = claim_detail[:benefit_claim_record] - #retrieve Claim code from record - claim_label_check = record[:claim_type_code] - - #If the claim label in VBMS does not match the new code, Update it - if(claim_label_check != new_code) - update_vbms(epe, original_code, new_code) - end - - end + class ClaimLabelChange + def update_vbms(epe, original_code, new_code) + # An End Product Update is created with the desired changes. + ep_update = EndProductUpdate.create!( + end_product_establishment: epe, + original_decision_review: epe.source, + original_code: original_code, + new_code: new_code, + user: User.system_user + ) + + # Perform the End Product Update. Note the return message. + ep_update.perform! + + # print the End Product Update to confirm the results. + pp ep_update end + + def claim_code_check(code) + # Declare hash + codes_hash = [] + + # File open and process. + File.open("lib/helpers/END_PRODUCT_CODES.json") do |f| + codes_hash = JSON.parse(f.read) + end + + # if claim code is in hash return true, else false. + codes_hash.key?(code) + end + + def validate_same_claim_type(old_code, new_code) + # Checks the sameness of the first two chacters as a substing + + unless old_code[0, 2] == new_code[0, 2] + puts("This is a different End Product, cannot claim label change. Aborting...") + fail Interrupt + end + end + + def update_caseflow(epe, new_code) + # Update the End Product in Caseflow. + epe.update(code: new_code) + + # Save the changes to the End Product. + epe.save + end + + def claim_label_updater(reference_id, original_code, new_code) + # The End products must be of the same type. (030, 040, 070) + validate_same_claim_type(original_code, new_code) + + # Check that the new claim code is valid + validate_claim_code(new_code, "Invalid new claim label code. Aborting...") + + # Check that the old claim code is valid for record + validate_claim_code(original_code, "Invalid orginal claim label code. Aborting...") + + # set the user + RequestStore[:current_user] = WarRoom.user + + # find the End Product by claim ID + epe = EndProductEstablishment.find_by(reference_id: reference_id) + + # validate EPE exists. + if epe.nil? + puts("Unable to find EPE for that reference id. Aborting...") + fail Interrupt + end + + # check the EPE by printing to console. + pp epe + + # check caseflow + if epe.code != new_code + update_caseflow(epe, new_code) + end + + # check VBMS + bgs = BGSService.new.client.claims + # fetch Claim details from VBMS by Claim_ID + claim_detail = bgs.find_claim_detail_by_id(epe.reference_id) + # retrieve specific record + record = claim_detail[:benefit_claim_record] + # retrieve Claim code from record + claim_label_check = record[:claim_type_code] + + # If the claim label in VBMS does not match the new code, Update it + if claim_label_check != new_code + update_vbms(epe, original_code, new_code) + end + end + end + + def validate_claim_code(claim_code, error_message) + unless claim_code_check(claim_code) + puts(error_message) + fail Interrupt + end + end end diff --git a/lib/helpers/duplicate_veteran_checker.rb b/lib/helpers/duplicate_veteran_checker.rb index e8691d9831c..96ed6b2fd99 100644 --- a/lib/helpers/duplicate_veteran_checker.rb +++ b/lib/helpers/duplicate_veteran_checker.rb @@ -52,7 +52,7 @@ def check_by_legacy_appeal_vacols_id(legacy_appeal_vacols_id) check_by_duplicate_veteran_file_number(la.veteran.file_number) end - def run_remediation_by_vacols_id(vacols_id) + def run_remediation_by_vacols_id(_vacols_id) la = LegacyAppeal.find_by_vacols_id(legacy_appeal_vacols_id) if la.nil? @@ -91,7 +91,7 @@ def check_by_duplicate_veteran_file_number(duplicate_veteran_file_number) fail Interrupt end - # Check if there in fact duplicate veterans. Can be duplicated with + # Check if there in fact duplicate veterans. Can be duplicated with # same partipant id or ssn dupe_vets = Veteran.where("ssn = ? or participant_id = ?", v.ssn, v.participant_id) @@ -110,7 +110,7 @@ def check_by_duplicate_veteran_file_number(duplicate_veteran_file_number) if other_v.file_number == old_file_number other_v = dupe_vets.last # First is duplicate veteran so get 2nd end - if other_v.file_number.empty? || other_v.file_number == old_file_number #if correct veteran has wrong file number + if other_v.file_number.empty? || other_v.file_number == old_file_number # if correct veteran has wrong file number puts("Both veterans have the same file_number or No file_number on the correct veteran. Aborting...") fail Interrupt elsif v.ssn.empty? && !other_v.ssn.empty? @@ -128,7 +128,7 @@ def check_by_duplicate_veteran_file_number(duplicate_veteran_file_number) end duplicate_relations = "" - + # Get the correct file number from a BGS call out file_number = BGSService.new.fetch_file_number_by_ssn(vet_ssn) @@ -137,88 +137,88 @@ def check_by_duplicate_veteran_file_number(duplicate_veteran_file_number) fail Interrupt end - # The following code runs through all possible relations + # The following code runs through all possible relations # to the duplicat evetran by file number or veteran id # collects all counts and displays all relations as = Appeal.where(veteran_file_number: old_file_number) - + as_count = as.count - duplicate_relations += as_count.to_s + " Appeals\n" + duplicate_relations += "#{as_count} Appeals\n" las = LegacyAppeal.where(vbms_id: convert_file_number_to_legacy(old_file_number)) las_count = las.count - duplicate_relations += las_count.to_s + " LegacyAppeals\n" - + duplicate_relations += "#{las_count} LegacyAppeals\n" + ahls = AvailableHearingLocations.where(veteran_file_number: old_file_number) - + ahls_count = ahls.count - duplicate_relations += ahls_count.to_s + " Avialable Hearing Locations\n" - + duplicate_relations += "#{ahls_count} Avialable Hearing Locations\n" + bpoas = BgsPowerOfAttorney.where(file_number: old_file_number) - + bpoas_count = bpoas.count - duplicate_relations += bpoas_count.to_s + " BgsPowerOfAAttorneys\n" - + duplicate_relations += "#{bpoas_count} BgsPowerOfAAttorneys\n" + ds = Document.where(file_number: old_file_number) - + ds_count = ds.count - duplicate_relations += ds_count.to_s + " Documents\n" + duplicate_relations += "#{ds_count} Documents\n" epes = EndProductEstablishment.where(veteran_file_number: old_file_number) - + epes_count = epes.count - duplicate_relations += epes_count.to_s + " EndProductEstablishment\n" + duplicate_relations += "#{epes_count} EndProductEstablishment\n" f8s = Form8.where(file_number: convert_file_number_to_legacy(old_file_number)) - + f8s_count = f8s.count - duplicate_relations += f8s_count.to_s + " Form8\n" - + duplicate_relations += "#{f8s_count} Form8\n" + hlrs = HigherLevelReview.where(veteran_file_number: old_file_number) - + hlrs_count = hlrs.count - duplicate_relations += hlrs_count.to_s + " HigherLevelReview\n" - + duplicate_relations += "#{hlrs_count} HigherLevelReview\n" + is_fn = Intake.where(veteran_file_number: old_file_number) - + is_fn_count = is_fn.count - duplicate_relations += is_fn_count.to_s + " Intakes related by file number\n" - + duplicate_relations += "#{is_fn_count} Intakes related by file number\n" + is_vi = Intake.where(veteran_id: v.id) - + is_vi_count = is_vi.count - duplicate_relations += is_vi_count.to_s + " Intakes related by veteran id\n" - + duplicate_relations += "#{is_vi_count} Intakes related by veteran id\n" + res = RampElection.where(veteran_file_number: old_file_number) - + res_count = res.count - duplicate_relations += res_count.to_s + " RampElection\n" - + duplicate_relations += "#{res_count} RampElection\n" + rrs = RampRefiling.where(veteran_file_number: old_file_number) - + rrs_count = rrs.count - duplicate_relations += rrs_count.to_s + " RampRefiling\n" - + duplicate_relations += "#{rrs_count} RampRefiling\n" + scs = SupplementalClaim.where(veteran_file_number: old_file_number) - + scs_count = scs.count - duplicate_relations += scs_count.to_s + " SupplementalClaim\n" + duplicate_relations += "#{scs_count} SupplementalClaim\n" - puts("Duplicate Veteran Relations:\n" + duplicate_relations) + puts("Duplicate Veteran Relations:\n#{duplicate_relations}") # Get relationship list for correct veteran @@ -228,81 +228,81 @@ def check_by_duplicate_veteran_file_number(duplicate_veteran_file_number) as2_count = as2.count - correct_relations += as2_count.to_s + " Appeals\n" + correct_relations += "#{as2_count} Appeals\n" las2 = LegacyAppeal.where(vbms_id: convert_file_number_to_legacy(file_number)) las2_count = las2.count - correct_relations += las2_count.to_s + " LegacyAppeals\n" + correct_relations += "#{las2_count} LegacyAppeals\n" ahls2 = AvailableHearingLocations.where(veteran_file_number: file_number) ahls2_count = ahls2.count - correct_relations += ahls2_count.to_s + " Avialable Hearing Locations\n" + correct_relations += "#{ahls2_count} Avialable Hearing Locations\n" bpoas2 = BgsPowerOfAttorney.where(file_number: file_number) bpoas2_count = bpoas2.count - correct_relations += bpoas2_count.to_s + " BgsPowerOfAAttorneys\n" + correct_relations += "#{bpoas2_count} BgsPowerOfAAttorneys\n" ds2 = Document.where(file_number: file_number) ds2_count = ds2.count - correct_relations += ds2_count.to_s + " Documents\n" + correct_relations += "#{ds2_count} Documents\n" epes2 = EndProductEstablishment.where(veteran_file_number: file_number) epes2_count = epes2.count - correct_relations += epes2_count.to_s + " EndProductEstablishment\n" + correct_relations += "#{epes2_count} EndProductEstablishment\n" f8s2 = Form8.where(file_number: convert_file_number_to_legacy(file_number)) f8s2_count = f8s2.count - correct_relations += f8s2_count.to_s + " Form8\n" + correct_relations += "#{f8s2_count} Form8\n" hlrs2 = HigherLevelReview.where(veteran_file_number: file_number) hlrs2_count = hlrs2.count - correct_relations += hlrs2_count.to_s + " HigherLevelReview\n" + correct_relations += "#{hlrs2_count} HigherLevelReview\n" is_fn2 = Intake.where(veteran_file_number: file_number) is_fn2_count = is_fn2.count - correct_relations += is_fn2_count.to_s + " Intakes related by file number\n" + correct_relations += "#{is_fn2_count} Intakes related by file number\n" is_vi2 = Intake.where(veteran_id: v.id) is_vi2_count = is_vi2.count - correct_relations += is_vi2_count.to_s + " Intakes related by veteran id\n" + correct_relations += "#{is_vi2_count} Intakes related by veteran id\n" res2 = RampElection.where(veteran_file_number: file_number) res2_count = res2.count - correct_relations += res2_count.to_s + " RampElection\n" + correct_relations += "#{res2_count} RampElection\n" rrs2 = RampRefiling.where(veteran_file_number: file_number) rrs2_count = rrs2.count - correct_relations += rrs2_count.to_s + " RampRefiling\n" + correct_relations += "#{rrs2_count} RampRefiling\n" scs2 = SupplementalClaim.where(veteran_file_number: file_number) scs2_count = scs2.count - correct_relations += scs2_count.to_s + " SupplementalClaim\n" + correct_relations += "#{scs2_count} SupplementalClaim\n" - puts("Correct Veteran Relations:\n" + correct_relations) + puts("Correct Veteran Relations:\n#{correct_relations}") end def run_remediation(duplicate_veteran_file_number) @@ -327,7 +327,7 @@ def run_remediation(duplicate_veteran_file_number) fail Interrupt end - # Check if there in fact duplicate veterans. Can be duplicated with + # Check if there in fact duplicate veterans. Can be duplicated with # same partipant id or ssn dupe_vets = Veteran.where("ssn = ? or participant_id = ?", v.ssn, v.participant_id) @@ -346,7 +346,7 @@ def run_remediation(duplicate_veteran_file_number) if other_v.file_number == old_file_number other_v = dupe_vets.last # First is duplicate veteran so get 2nd end - if other_v.file_number.empty? || other_v.file_number == old_file_number #if correct veteran has wrong file number + if other_v.file_number.empty? || other_v.file_number == old_file_number # if correct veteran has wrong file number puts("Both veterans have the same file_number or No file_number on the correct veteran. Aborting...") fail Interrupt elsif v.ssn.empty? && !other_v.ssn.empty? @@ -364,7 +364,7 @@ def run_remediation(duplicate_veteran_file_number) end duplicate_relations = "" - + # Get the correct file number from a BGS call out file_number = BGSService.new.fetch_file_number_by_ssn(vet_ssn) @@ -373,88 +373,88 @@ def run_remediation(duplicate_veteran_file_number) fail Interrupt end - # The following code runs through all possible relations + # The following code runs through all possible relations # to the duplicat evetran by file number or veteran id # collects all counts and displays all relations as = Appeal.where(veteran_file_number: old_file_number) - + as_count = as.count - duplicate_relations += as_count.to_s + " Appeals\n" + duplicate_relations += "#{as_count} Appeals\n" las = LegacyAppeal.where(vbms_id: convert_file_number_to_legacy(old_file_number)) las_count = las.count - duplicate_relations += las_count.to_s + " LegacyAppeals\n" - + duplicate_relations += "#{las_count} LegacyAppeals\n" + ahls = AvailableHearingLocations.where(veteran_file_number: old_file_number) - + ahls_count = ahls.count - duplicate_relations += ahls_count.to_s + " Avialable Hearing Locations\n" - + duplicate_relations += "#{ahls_count} Avialable Hearing Locations\n" + bpoas = BgsPowerOfAttorney.where(file_number: old_file_number) - + bpoas_count = bpoas.count - duplicate_relations += bpoas_count.to_s + " BgsPowerOfAAttorneys\n" - + duplicate_relations += "#{bpoas_count} BgsPowerOfAAttorneys\n" + ds = Document.where(file_number: old_file_number) - + ds_count = ds.count - duplicate_relations += ds_count.to_s + " Documents\n" + duplicate_relations += "#{ds_count} Documents\n" epes = EndProductEstablishment.where(veteran_file_number: old_file_number) - + epes_count = epes.count - duplicate_relations += epes_count.to_s + " EndProductEstablishment\n" + duplicate_relations += "#{epes_count} EndProductEstablishment\n" f8s = Form8.where(file_number: convert_file_number_to_legacy(old_file_number)) - + f8s_count = f8s.count - duplicate_relations += f8s_count.to_s + " Form8\n" - + duplicate_relations += "#{f8s_count} Form8\n" + hlrs = HigherLevelReview.where(veteran_file_number: old_file_number) - + hlrs_count = hlrs.count - duplicate_relations += hlrs_count.to_s + " HigherLevelReview\n" - + duplicate_relations += "#{hlrs_count} HigherLevelReview\n" + is_fn = Intake.where(veteran_file_number: old_file_number) - + is_fn_count = is_fn.count - duplicate_relations += is_fn_count.to_s + " Intakes related by file number\n" - + duplicate_relations += "#{is_fn_count} Intakes related by file number\n" + is_vi = Intake.where(veteran_id: v.id) - + is_vi_count = is_vi.count - duplicate_relations += is_vi_count.to_s + " Intakes related by veteran id\n" - + duplicate_relations += "#{is_vi_count} Intakes related by veteran id\n" + res = RampElection.where(veteran_file_number: old_file_number) - + res_count = res.count - duplicate_relations += res_count.to_s + " RampElection\n" - + duplicate_relations += "#{res_count} RampElection\n" + rrs = RampRefiling.where(veteran_file_number: old_file_number) - + rrs_count = rrs.count - duplicate_relations += rrs_count.to_s + " RampRefiling\n" - + duplicate_relations += "#{rrs_count} RampRefiling\n" + scs = SupplementalClaim.where(veteran_file_number: old_file_number) - + scs_count = scs.count - duplicate_relations += scs_count.to_s + " SupplementalClaim\n" + duplicate_relations += "#{scs_count} SupplementalClaim\n" - puts("Duplicate Veteran Relations:\n" + duplicate_relations) + puts("Duplicate Veteran Relations:\n#{duplicate_relations}") # Get relationship list for correct veteran @@ -464,81 +464,81 @@ def run_remediation(duplicate_veteran_file_number) as2_count = as2.count - correct_relations += as2_count.to_s + " Appeals\n" + correct_relations += "#{as2_count} Appeals\n" las2 = LegacyAppeal.where(vbms_id: convert_file_number_to_legacy(file_number)) las2_count = las2.count - correct_relations += las2_count.to_s + " LegacyAppeals\n" + correct_relations += "#{las2_count} LegacyAppeals\n" ahls2 = AvailableHearingLocations.where(veteran_file_number: file_number) ahls2_count = ahls2.count - correct_relations += ahls2_count.to_s + " Avialable Hearing Locations\n" + correct_relations += "#{ahls2_count} Avialable Hearing Locations\n" bpoas2 = BgsPowerOfAttorney.where(file_number: file_number) bpoas2_count = bpoas2.count - correct_relations += bpoas2_count.to_s + " BgsPowerOfAAttorneys\n" + correct_relations += "#{bpoas2_count} BgsPowerOfAAttorneys\n" ds2 = Document.where(file_number: file_number) ds2_count = ds2.count - correct_relations += ds2_count.to_s + " Documents\n" + correct_relations += "#{ds2_count} Documents\n" epes2 = EndProductEstablishment.where(veteran_file_number: file_number) epes2_count = epes2.count - correct_relations += epes2_count.to_s + " EndProductEstablishment\n" + correct_relations += "#{epes2_count} EndProductEstablishment\n" f8s2 = Form8.where(file_number: convert_file_number_to_legacy(file_number)) f8s2_count = f8s2.count - correct_relations += f8s2_count.to_s + " Form8\n" + correct_relations += "#{f8s2_count} Form8\n" hlrs2 = HigherLevelReview.where(veteran_file_number: file_number) hlrs2_count = hlrs2.count - correct_relations += hlrs2_count.to_s + " HigherLevelReview\n" + correct_relations += "#{hlrs2_count} HigherLevelReview\n" is_fn2 = Intake.where(veteran_file_number: file_number) is_fn2_count = is_fn2.count - correct_relations += is_fn2_count.to_s + " Intakes related by file number\n" + correct_relations += "#{is_fn2_count} Intakes related by file number\n" is_vi2 = Intake.where(veteran_id: v.id) is_vi2_count = is_vi2.count - correct_relations += is_vi2_count.to_s + " Intakes related by veteran id\n" + correct_relations += "#{is_vi2_count} Intakes related by veteran id\n" res2 = RampElection.where(veteran_file_number: file_number) res2_count = res2.count - correct_relations += res2_count.to_s + " RampElection\n" + correct_relations += "#{res2_count} RampElection\n" rrs2 = RampRefiling.where(veteran_file_number: file_number) rrs2_count = rrs2.count - correct_relations += rrs2_count.to_s + " RampRefiling\n" + correct_relations += "#{rrs2_count} RampRefiling\n" scs2 = SupplementalClaim.where(veteran_file_number: file_number) scs2_count = scs2.count - correct_relations += scs2_count.to_s + " SupplementalClaim\n" + correct_relations += "#{scs2_count} SupplementalClaim\n" - puts("Correct Veteran Relations:\n" + correct_relations) + puts("Correct Veteran Relations:\n#{correct_relations}") # migrate duplicate veteran relations to correct veteran @@ -547,7 +547,7 @@ def run_remediation(duplicate_veteran_file_number) as_update_count = as.update_all(veteran_file_number: file_number) if as_update_count != as_count - error_relations += "Expected " + as_count + " Appeals updated, but " + as_update_count + "were updated.\n" + error_relations += "Expected #{as_count} Appeals updated, but #{as_update_count}were updated.\n" end vbms_id = LegacyAppeal.convert_file_number_to_vacols(file_number) @@ -561,73 +561,76 @@ def run_remediation(duplicate_veteran_file_number) las_update_count = las.update_all(vbms_id: vbms_id) if las_update_count != las_count - error_relations += "Expected " + las_count + " LegacyAppeals updated, but " + las_update_count + "were updated.\n" + error_relations += "Expected #{las_count} LegacyAppeals updated, but #{las_update_count}were updated.\n" end ahls_update_count = ahls.update_all(veteran_file_number: file_number) if ahls_update_count != ahls_count - error_relations += "Expected " + ahls_count + " HearingLocations updated, but " + ahls_update_count + "were updated.\n" + error_relations += "Expected #{ahls_count} HearingLocations updated, but #{ahls_update_count}were updated.\n" end bpoas_update_count = bpoas.update_all(file_number: file_number) if bpoas_update_count != bpoas_count - error_relations += "Expected " + bpoas_count + " BgsPowerOfAttorneys updated, but " + as_update_count + "were updated.\n" + error_relations += "Expected #{bpoas_count} BgsPowerOfAttorneys updated, but #{as_update_count}were updated.\n" end ds_update_count = ds.update_all(file_number: file_number) if ds_update_count != ds_count - error_relations += "Expected " + ds_count + " Documents updated, but " + ds_update_count + "were updated.\n" + error_relations += "Expected #{ds_count} Documents updated, but #{ds_update_count}were updated.\n" end epes_update_count = epes.update_all(veteran_file_number: file_number) if epes_update_count != epes_count - error_relations += "Expected " + epes_count + " EndProductEstablishments updated, but " + epes_update_count + "were updated\n" + error_relations += "Expected #{epes_count} EndProductEstablishments updated, but #{epes_update_count}were updated\n" end - f8s_update_count = f8s.update_all(file_number: vbms_id) + f8s_update_count = f8s.update_all(file_number: vbms_id) if f8s_update_count != f8s_count - error_relations += "Expected " + f8s_count + " Form8s updated, but " + f8s_update_count + "were updated.\n" + error_relations += "Expected #{f8s_count} Form8s updated, but #{f8s_update_count}were updated.\n" end hlrs_update_count = hlrs.update_all(veteran_file_number: file_number) if hlrs_update_count != hlrs_count - error_relations += "Expected " + hlrs_count + " HigherLevelReviews updated, but " + hlrs_update_count + "were updated.\n" + error_relations += "Expected #{hlrs_count} HigherLevelReviews updated, \ + but #{hlrs_update_count}were updated.\n" end is_fn_update_count = is_fn.update_all(veteran_file_number: file_number) if is_fn_update_count != is_fn_count - error_relations += "Expected " + is_fn_count + " Intakes by file number updated, but " + is_fn_update_count + "were updated.\n" + error_relations += "Expected #{is_fn_count} Intakes by file number updated, \ + but #{is_fn_update_count}were updated.\n" end is_vi_update_count = is_vi.update_all(veteran_id: v2.id) if is_vi_update_count != is_vi_count - error_relations += "Expected " + is_vi_count + " Intakes by veteran id updated, but " + is_vi_update_count + "were updated.\n" + error_relations += "Expected #{is_vi_count} Intakes by veteran idupdated, \ + but #{is_vi_update_count}were updated.\n" end res_update_count = res.update_all(veteran_file_number: file_number) if res_update_count != res_count - error_relations += "Expected " + res_count + " RampElections updated, but " + res_update_count + "were updated.\n" + error_relations += "Expected #{res_count} RampElections updated, but #{res_update_count}were updated.\n" end rrs_update_count = rrs.update_all(veteran_file_number: file_number) if rrs_update_count != rrs_count - error_relations += "Expected " + rrs_count + " RampRefilings updated, but " + rrs_update_count + "were updated.\n" + error_relations += "Expected #{rrs_count} RampRefilings updated, but #{rrs_update_count}were updated.\n" end scs_update_count = scs.update_all(veteran_file_number: file_number) if scs_update_count != scs_count - error_relations += "Expected " + scs_count + " SupplimentalCliams updated, but " + scs_update_count + "were updated.\n" + error_relations += "Expected #{scs_count} SupplimentalCliams updated, but #{scs_update_count}were updated.\n" end if !error_relations.empty? @@ -640,24 +643,24 @@ def run_remediation(duplicate_veteran_file_number) # Check if duplicate veteran relationships are all gone existing_relations = "" as = Appeal.where(veteran_file_number: old_file_number) - + as_count = as.count if as_count != 0 - existing_relations += as_count.to_s + " Appeal still exists.\n" + existing_relations += "#{as_count} Appeal still exists.\n" end las = LegacyAppeal.where(vbms_id: LegacyAppeal.convert_file_number_to_vacols(old_file_number)) las_count = las.count if las_count != 0 - existing_relations += as_count.to_s + " LegacyAppeal still exists.\n" + existing_relations += "#{as_count} LegacyAppeal still exists.\n" end ahls = AvailableHearingLocations.where(veteran_file_number: old_file_number) ahls_count = ahls.count if ahls_count != 0 - existing_relations += ahls_count.to_s + " AvaialbelHearings still exists.\n" + existing_relations += "#{ahls_count} AvaialbelHearings still exists.\n" end bpoas = BgsPowerOfAttorney.where(file_number: old_file_number) @@ -665,7 +668,7 @@ def run_remediation(duplicate_veteran_file_number) bpoas_count = bpoas.count if bpoas_count != 0 - existing_relations += bpoas_count.to_s + " BgsPowerOfAttorneys still exists.\n" + existing_relations += "#{bpoas_count} BgsPowerOfAttorneys still exists.\n" end ds = Document.where(file_number: old_file_number) @@ -673,7 +676,7 @@ def run_remediation(duplicate_veteran_file_number) ds_count = ds.count if ds_count != 0 - existing_relations += ds_count.to_s + " Document still exists.\n" + existing_relations += "#{ds_count} Document still exists.\n" end epes = EndProductEstablishment.where(veteran_file_number: old_file_number) @@ -681,7 +684,7 @@ def run_remediation(duplicate_veteran_file_number) epes_count = epes.count if epes_count != 0 - existing_relations += epes_count.to_s + " EndProductEstablishment still exists.\n" + existing_relations += "#{epes_count} EndProductEstablishment still exists.\n" end f8s = Form8.where(file_number: LegacyAppeal.convert_file_number_to_vacols(old_file_number)) @@ -689,7 +692,7 @@ def run_remediation(duplicate_veteran_file_number) f8s_count = f8s.count if f8s_count != 0 - existing_relations += f8s_count.to_s + " Form8 still exists.\n" + existing_relations += "#{f8s_count} Form8 still exists.\n" end hlrs = HigherLevelReview.where(veteran_file_number: old_file_number) @@ -697,7 +700,7 @@ def run_remediation(duplicate_veteran_file_number) hlrs_count = hlrs.count if hlrs_count != 0 - existing_relations += hlrs_count.to_s + " HilerLevelReview still exists.\n" + existing_relations += "#{hlrs_count} HilerLevelReview still exists.\n" end is_fn = Intake.where(veteran_file_number: old_file_number) @@ -705,7 +708,7 @@ def run_remediation(duplicate_veteran_file_number) is_fn_count = is_fn.count if is_fn_count != 0 - existing_relations += is_fn_count.to_s + " Intake by file_number still exists.\n" + existing_relations += "#{is_fn_count} Intake by file_number still exists.\n" end is_vi = Intake.where(veteran_id: v.id) @@ -713,7 +716,7 @@ def run_remediation(duplicate_veteran_file_number) is_vi_count = is_vi.count if is_vi_count != 0 - existing_relations += is_vi_count.to_s + " intake by vet id still exists.\n" + existing_relations += "#{is_vi_count} intake by vet id still exists.\n" end res = RampElection.where(veteran_file_number: old_file_number) @@ -721,7 +724,7 @@ def run_remediation(duplicate_veteran_file_number) res_count = res.count if res_count != 0 - existing_relations += res_count.to_s + " RampElection still exists.\n" + existing_relations += "#{res_count} RampElection still exists.\n" end rrs = RampRefiling.where(veteran_file_number: old_file_number) @@ -729,7 +732,7 @@ def run_remediation(duplicate_veteran_file_number) rrs_count = rrs.count if rrs_count != 0 - existing_relations += rrs_count.to_s + " RampRefiling still exists.\n" + existing_relations += "#{rrs_count} RampRefiling still exists.\n" end scs = SupplementalClaim.where(veteran_file_number: old_file_number) @@ -737,11 +740,11 @@ def run_remediation(duplicate_veteran_file_number) scs_count = scs.count if scs_count != 0 - existing_relations += scs_count.to_s + " SupplementalClaim still exists.\n" + existing_relations += "#{scs_count} SupplementalClaim still exists.\n" end if !existing_relations.empty? - puts("Duplicate veteran still has associated records. Can not delete untill resolved:\n" + existing_relations) + puts("Duplicate veteran still has associated records. Can not delete untill resolved:\n#{existing_relations}") fail Interrupt end @@ -756,6 +759,6 @@ def run_remediation(duplicate_veteran_file_number) private def convert_file_number_to_legacy(file_number) - return LegacyAppeal.convert_file_number_to_vacols(file_number) + LegacyAppeal.convert_file_number_to_vacols(file_number) end end diff --git a/lib/helpers/report_load_end_product_sync.rb b/lib/helpers/report_load_end_product_sync.rb index eafe06669c8..bf270e45c03 100644 --- a/lib/helpers/report_load_end_product_sync.rb +++ b/lib/helpers/report_load_end_product_sync.rb @@ -3,8 +3,7 @@ module WarRoom # Purpose: to find and sync EPs in Caseflow with VBMS class ReportLoadEndProductSync - - require 'csv' + require "csv" S3_BUCKET_NAME = "ep-priority-sync" # Currently, out of sync EPs are tracked in OAR report loads that are sent over and then @@ -76,7 +75,6 @@ def run_for_cancelled_eps(batch_limit) conn.close end - private ###################################################################### @@ -106,8 +104,7 @@ def call_sync_by_report_load(ep_ref, rep_load, conn) conn.raw_connection.exec_params("UPDATE ep_establishment_workaround SET synced_status = $1, last_synced_at = $2, sync_duration = $3, prev_sync_status = $4 where reference_id = $5 AND report_load = $6", [original_ep.synced_status, Time.zone.now, elapsed_time.to_i, - sync_before, ep_ref, rep_load]) - + sync_before, ep_ref, rep_load]) rescue StandardError => error end_time = Time.now.to_f elapsed_time = (end_time - start_time) * 1000 @@ -115,12 +112,11 @@ def call_sync_by_report_load(ep_ref, rep_load, conn) conn.raw_connection.exec_params("UPDATE ep_establishment_workaround SET synced_error = $1, synced_status = $2, last_synced_at = $3, sync_duration = $4, prev_sync_status = $5 where reference_id = $6 AND report_load = $7", [error.message, - original_ep&.synced_status ? original_ep.synced_status : nil, Time.zone.now, elapsed_time.to_i, - sync_before, ep_ref, rep_load]) + original_ep&.synced_status ? original_ep.synced_status : nil, Time.zone.now, elapsed_time.to_i, + sync_before, ep_ref, rep_load]) end end - #################################################################### # # The rest of the code is specific to the priority EP sync @@ -128,9 +124,9 @@ def call_sync_by_report_load(ep_ref, rep_load, conn) #################################################################### # Grab txt file of previously errored EP reference ids from s3 and return as an array - def get_error_ids + def get_error_ids # rubocop:disable Naming/AccessorMethodName error_txt = S3Service.fetch_content(S3_BUCKET_NAME + "/error_ids.txt") - error_txt.gsub("\r","").split("\n").map{ |obj| obj[1...-1] } + error_txt.delete("\r").split("\n").map { |obj| obj[1...-1] } end # Method to log errors to S3 error_ids txt file in real time in case of @@ -140,13 +136,13 @@ def get_error_ids def realtime_log_error_to_s3(reference_id) error_txt = S3Service.fetch_content(S3_BUCKET_NAME + "/error_ids.txt") error_txt << "\r\n" - error_txt << '"' + "#{reference_id}"+ '"' + error_txt << '"' + reference_id.to_s + '"' S3Service.store_file(S3_BUCKET_NAME + "/error_ids.txt", error_txt) end # Grab cleared EPs that are out of sync def get_cleared_eps(batch_limit, error_ids, conn) - error_ids = error_ids.map { |s| "'#{s}'" }.join(', ') + error_ids = error_ids.map { |s| "'#{s}'" }.join(", ") raw_sql = <<~SQL SELECT @@ -176,7 +172,7 @@ def get_cleared_eps(batch_limit, error_ids, conn) # Grab cancelled EPs that are out of sync def get_cancelled_eps(batch_limit, error_ids, conn) - error_ids = error_ids.map { |s| "'#{s}'" }.join(', ') + error_ids = error_ids.map { |s| "'#{s}'" }.join(", ") raw_sql = <<~SQL SELECT @@ -206,7 +202,7 @@ def get_cancelled_eps(batch_limit, error_ids, conn) # Method to priority sync with VBMS # Also adds data to log files - def call_priority_sync(ep_ref, conn) + def call_priority_sync(ep_ref, _conn) begin epe = EndProductEstablishment.find_by(reference_id: ep_ref) sync_status_before = epe.synced_status @@ -249,13 +245,13 @@ def build_csv(input_data) error ] input_data.each do |data| - csv << [ - data.reference_id, - data.last_synced_at, - data.synced_status, - data.prev_synced_status, - data.error - ].flatten + csv << [ + data.reference_id, + data.last_synced_at, + data.synced_status, + data.prev_synced_status, + data.error + ].flatten end end end diff --git a/lib/helpers/unrecognized_appellant.rb b/lib/helpers/unrecognized_appellant.rb index 293b0b8d92e..abd210bf9c9 100644 --- a/lib/helpers/unrecognized_appellant.rb +++ b/lib/helpers/unrecognized_appellant.rb @@ -1,65 +1,73 @@ -module WarRoom - class UnrecognizedAppellant - def self.run(dispatch_task_id) - RequestStore[:current_user] = WarRoom.user - - ec = EstablishClaim.find(dispatch_task_id) - la = ec.appeal +# frozen_string_literal: true +module WarRoom + class UnrecognizedAppellant + def self.run(dispatch_task_id) + RequestStore[:current_user] = WarRoom.user - return false unless la.veteran.nil? + ec = EstablishClaim.find(dispatch_task_id) + la = ec.appeal - # Issues are printed for ticketing information - iss = la.issues - puts "===============ISSUES===============" - puts iss.count > 0 ? iss : "No issues for this appeal" - puts "====================================" + return false unless la.veteran.nil? - # Temporarily unblock the user by unassigning the task from the user and putting it back to the bottom of the queue of dispatch tasks to get assigned - # by setting the created_at time to now we put the task to the end of the queue because the tasks are sorted oldest to newest - ec.update!(user_id: nil, assigned_at: nil, started_at: nil, created_at: Time.now, aasm_state: "unassigned") + # Issues are printed for ticketing information + iss = la.issues + puts "===============ISSUES===============" + puts((iss.count > 0) ? iss : "No issues for this appeal") + puts "====================================" - # Get information about the appeal for the dispatch task and pass it along to OAR - # This information is sent to Jennifer.Schleicher@va.gov in an encrypted email - veteran_info = { - vacols_appeal_id: la.vacols_id, - veteran_name: [la.veteran_first_name, la.veteran_middle_initial, la.veteran_last_name, la.veteran_name_suffix].compact.join(" "), - veteran_file_number: la.veteran_file_number - } - puts veteran_info - return veteran_info - end + # Temporarily unblock the user by unassigning the task from the user and putting it + # back to the bottom of the queue of dispatch tasks to get assigned + # by setting the created_at time to now we put the task to the end of the queue because + # the tasks are sorted oldest to newest + ec.update!(user_id: nil, assigned_at: nil, started_at: nil, created_at: Time.zone.now, aasm_state: "unassigned") - def self.run_complete(dispatch_task_id) - RequestStore[:current_user] = WarRoom.user + # Get information about the appeal for the dispatch task and pass it along to OAR + # This information is sent to Jennifer.Schleicher@va.gov in an encrypted email + veteran_info = { + vacols_appeal_id: la.vacols_id, + veteran_name: [la.veteran_first_name, + la.veteran_middle_initial, + la.veteran_last_name, + la.veteran_name_suffix].compact.join(" "), + veteran_file_number: la.veteran_file_number + } + puts veteran_info + veteran_info + end - ec = EstablishClaim.find(dispatch_task_id) - la = ec.appeal + def self.run_complete(dispatch_task_id) + RequestStore[:current_user] = WarRoom.user + ec = EstablishClaim.find(dispatch_task_id) + la = ec.appeal - return "Veteran was not nil." unless la.veteran.nil? + return "Veteran was not nil." unless la.veteran.nil? - # Issues are printed for ticketing information - iss = la.issues - puts "===============ISSUES===============" - puts iss.count > 0 ? iss : "No issues for this appeal" - puts "====================================" + # Issues are printed for ticketing information + iss = la.issues + puts "===============ISSUES===============" + puts((iss.count > 0) ? iss : "No issues for this appeal") + puts "====================================" - return "User id was not nil." unless ec.user_id.nil? + return "User id was not nil." unless ec.user_id.nil? - # Unblock the user by completing the task - ec.update!(aasm_state: "completed", - comment: "Task has been completed by Caseflow dev team as per instruction by OAR") + # Unblock the user by completing the task + ec.update!(aasm_state: "completed", + comment: "Task has been completed by Caseflow dev team as per instruction by OAR") - # Get information about the appeal for the dispatch task and pass it along to OAR - # This information is sent to Jennifer.Schleicher@va.gov in an encrypted email - veteran_info = { - vacols_appeal_id: la.vacols_id, - veteran_name: [la.veteran_first_name, la.veteran_middle_initial, la.veteran_last_name, la.veteran_name_suffix].compact.join(" "), - veteran_file_number: la.veteran_file_number - } - puts veteran_info - return veteran_info - end + # Get information about the appeal for the dispatch task and pass it along to OAR + # This information is sent to Jennifer.Schleicher@va.gov in an encrypted email + veteran_info = { + vacols_appeal_id: la.vacols_id, + veteran_name: [la.veteran_first_name, + la.veteran_middle_initial, + la.veteran_last_name, + la.veteran_name_suffix].compact.join(" "), + veteran_file_number: la.veteran_file_number + } + puts veteran_info + veteran_info end + end end diff --git a/spec/jobs/amo_metrics_report_job_spec.rb b/spec/jobs/amo_metrics_report_job_spec.rb index 7c67fdebd59..b4629909d4a 100644 --- a/spec/jobs/amo_metrics_report_job_spec.rb +++ b/spec/jobs/amo_metrics_report_job_spec.rb @@ -3,11 +3,11 @@ describe AMOMetricsReportJob, :postgres do include_context "Metrics Reports" - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:report) do "AMO metrics report 2019-03-01 to 2019-03-29\nSupplemental Claims 1 established, median 24:00:00 average 24:00:00\nSupplemental Claims newly stuck: 0\nSupplemental Claims total stuck: 0\nHigher Level Reviews 1 established, median 00:00:00 average 00:00:00\nHigher Level Reviews newly stuck: 0\nHigher Level Reviews total stuck: 0\ntype,total,in_progress,cancelled,processed,established_within_seven_days,established_within_seven_days_percent,median,avg,max,min\nsupplemental_claims,1,0,0,1,1,100.0,24:00:00,24:00:00,24:00:00,24:00:00\nhigher_level_reviews,1,0,1,0,0,0.0,00:00:00,00:00:00,00:00:00,00:00:00\nrequest_issues_updates,1,0,0,1,1,100.0,24:00:00,24:00:00,24:00:00,24:00:00\n" end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength describe "#perform" do before do diff --git a/spec/jobs/annual_metrics_report_job_spec.rb b/spec/jobs/annual_metrics_report_job_spec.rb index d26b68771e7..622b053e2d9 100644 --- a/spec/jobs/annual_metrics_report_job_spec.rb +++ b/spec/jobs/annual_metrics_report_job_spec.rb @@ -3,7 +3,7 @@ describe AnnualMetricsReportJob, :postgres do include_context "Metrics Reports" - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:report) do [ "Annual report 2018-03-01 to 2019-02-28", @@ -21,7 +21,7 @@ "" # We end the body of the message with a newline character. ].join("\n") end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength describe "#perform" do before do diff --git a/spec/jobs/monthly_metrics_report_job_spec.rb b/spec/jobs/monthly_metrics_report_job_spec.rb index ae2c92d5622..98328491726 100644 --- a/spec/jobs/monthly_metrics_report_job_spec.rb +++ b/spec/jobs/monthly_metrics_report_job_spec.rb @@ -3,11 +3,11 @@ describe MonthlyMetricsReportJob, :postgres do include_context "Metrics Reports" - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:report) do "Monthly report 2019-02-01 to 2019-02-28\nPercentage of all cases certified with Caseflow: 100.0%\nAppeals established within 7 days: 1 (100%)\nSupplemental Claims within 7 days: 1 (25.0%)\nHigher Level Reviews within 7 days: 2 (50.0%)\ntype,total,in_progress,cancelled,processed,established_within_seven_days,established_within_seven_days_percent,median,avg,max,min\nsupplemental_claims,4,1,1,2,1,25.0,373:30:00,373:30:00,743:00:00,04:00:00\nhigher_level_reviews,4,1,0,3,2,50.0,04:00:00,249:20:00,743:00:00,01:00:00\nrequest_issues_updates,3,0,1,2,1,33.33,384:00:00,384:00:00,767:00:00,01:00:00\n" end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength describe "#perform" do before do diff --git a/spec/jobs/quarterly_metrics_report_job_spec.rb b/spec/jobs/quarterly_metrics_report_job_spec.rb index 5dd6a1d482a..39ebae36d2c 100644 --- a/spec/jobs/quarterly_metrics_report_job_spec.rb +++ b/spec/jobs/quarterly_metrics_report_job_spec.rb @@ -3,7 +3,7 @@ describe QuarterlyMetricsReportJob, :postgres do include_context "Metrics Reports" - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:report) do [ "Quarterly report 2018-12-01 to 2019-02-28", @@ -23,7 +23,7 @@ "" # We end the body of the message with a newline character. ].join("\n") end - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength describe "#perform" do before do diff --git a/spec/models/idt/token_spec.rb b/spec/models/idt/token_spec.rb index 6401aecfa79..f029e2133b0 100644 --- a/spec/models/idt/token_spec.rb +++ b/spec/models/idt/token_spec.rb @@ -8,9 +8,9 @@ let(:css_id) { "TEST_ID" } let(:key_token_pair) { Idt::Token.generate_one_time_key_and_proposed_token } - # rubocop:disable Metrics/LineLength + # rubocop:disable Layout/LineLength let(:invalid_token) { "9373a256a2ac3c3bd320adeeb8a1e4d996ef064d1332357954410f25740bf0c17b6565e152760c461a85587e6a6845457f955ccfa20a8e462a77b776eb10b72c" } - # rubocop:enable Metrics/LineLength + # rubocop:enable Layout/LineLength context "#generate_one_time_key_and_proposed_token" do it "generates tokens and keys" do