-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ClayS/APPEALS-4963
- Loading branch information
Showing
26 changed files
with
1,084 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# frozen_string_literal: true | ||
|
||
class BgsShareErrorFixJob < CaseflowJob | ||
ERROR_TEXT = "ShareError" | ||
STUCK_JOB_REPORT_SERVICE = StuckJobReportService.new | ||
|
||
def perform | ||
clear_hlr_errors if hlrs_with_errors.present? | ||
clear_rius_errors if rius_with_errors.present? | ||
clear_bge_errors if bges_with_errors.present? | ||
STUCK_JOB_REPORT_SERVICE.write_log_report(ERROR_TEXT) | ||
end | ||
|
||
def clear_rius_errors | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(rius_with_errors.count, ERROR_TEXT) | ||
rius_with_errors.each do |riu| | ||
epe = EndProductEstablishment.find_by( | ||
id: riu.review_id | ||
) | ||
next if epe.established_at.blank? | ||
|
||
resolve_error_on_records(riu) | ||
STUCK_JOB_REPORT_SERVICE.append_single_record(riu.class.name, riu.id) | ||
end | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(rius_with_errors.count, ERROR_TEXT) | ||
end | ||
|
||
def clear_hlr_errors | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(hlrs_with_errors.count, ERROR_TEXT) | ||
|
||
hlrs_with_errors.each do |hlr| | ||
epe = EndProductEstablishment.find_by( | ||
veteran_file_number: hlr.veteran_file_number | ||
) | ||
next if epe.established_at.blank? | ||
|
||
resolve_error_on_records(hlr) | ||
STUCK_JOB_REPORT_SERVICE.append_single_record(hlr.class.name, hlr.id) | ||
end | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(hlrs_with_errors.count, ERROR_TEXT) | ||
end | ||
|
||
def clear_bge_errors | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(bges_with_errors.count, ERROR_TEXT) | ||
|
||
bges_with_errors.each do |bge| | ||
next if bge.end_product_establishment.established_at.blank? | ||
|
||
resolve_error_on_records(bge) | ||
STUCK_JOB_REPORT_SERVICE.append_single_record(bge.class.name, bge.id) | ||
end | ||
STUCK_JOB_REPORT_SERVICE.append_record_count(bges_with_errors.count, ERROR_TEXT) | ||
end | ||
|
||
def hlrs_with_errors | ||
HigherLevelReview.where("establishment_error ILIKE?", "%#{ERROR_TEXT}%") | ||
end | ||
|
||
def rius_with_errors | ||
RequestIssuesUpdate.where("error ILIKE?", "%#{ERROR_TEXT}%") | ||
end | ||
|
||
def bges_with_errors | ||
BoardGrantEffectuation.where("decision_sync_error ILIKE?", "%#{ERROR_TEXT}%") | ||
end | ||
|
||
private | ||
|
||
# :reek:FeatureEnvy | ||
def resolve_error_on_records(object_type) | ||
ActiveRecord::Base.transaction do | ||
object_type.clear_error! | ||
rescue StandardError => error | ||
log_error(error) | ||
STUCK_JOB_REPORT_SERVICE.append_errors(object_type.class.name, object_type.id, error) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# frozen_string_literal: true | ||
|
||
class ClaimDateDtFixJob < CaseflowJob | ||
ERROR_TEXT = "ClaimDateDt" | ||
|
||
attr_reader :stuck_job_report_service | ||
|
||
def initialize | ||
@stuck_job_report_service = StuckJobReportService.new | ||
end | ||
|
||
def perform | ||
process_decision_documents | ||
end | ||
|
||
def process_decision_documents | ||
return if decision_docs_with_errors.blank? | ||
|
||
stuck_job_report_service.append_record_count(decision_docs_with_errors.count, ERROR_TEXT) | ||
|
||
decision_docs_with_errors.each do |single_decision_document| | ||
next unless valid_decision_document?(single_decision_document) | ||
|
||
process_decision_document(single_decision_document) | ||
end | ||
|
||
stuck_job_report_service.append_record_count(decision_docs_with_errors.count, ERROR_TEXT) | ||
|
||
stuck_job_report_service.write_log_report(ERROR_TEXT) | ||
end | ||
|
||
def valid_decision_document?(decision_document) | ||
decision_document.processed_at.present? && | ||
decision_document.uploaded_to_vbms_at.present? | ||
end | ||
|
||
# :reek:FeatureEnvy | ||
def process_decision_document(decision_document) | ||
ActiveRecord::Base.transaction do | ||
decision_document.clear_error! | ||
rescue StandardError => error | ||
log_error(error) | ||
stuck_job_report_service.append_errors(decision_document.class.name, decision_document.id, error) | ||
end | ||
end | ||
|
||
def decision_docs_with_errors | ||
DecisionDocument.where("error ILIKE ?", "%#{ERROR_TEXT}%") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
class ClaimNotEstablishedFixJob < CaseflowJob | ||
ERROR_TEXT = "Claim not established." | ||
EPECODES = %w[030 040 930 682].freeze | ||
|
||
attr_reader :stuck_job_report_service | ||
|
||
def initialize | ||
@stuck_job_report_service = StuckJobReportService.new | ||
end | ||
|
||
def perform | ||
return if decision_docs_with_errors.blank? | ||
|
||
stuck_job_report_service.append_record_count(decision_docs_with_errors.count, ERROR_TEXT) | ||
|
||
decision_docs_with_errors.each do |single_decision_document| | ||
file_number = single_decision_document.veteran.file_number | ||
epe_array = EndProductEstablishment.where(veteran_file_number: file_number) | ||
validated_epes = epe_array.map { |epe| validate_epe(epe) } | ||
|
||
stuck_job_report_service.append_single_record(single_decision_document.class.name, single_decision_document.id) | ||
|
||
resolve_error_on_records(single_decision_document, validated_epes) | ||
end | ||
|
||
stuck_job_report_service.append_record_count(decision_docs_with_errors.count, ERROR_TEXT) | ||
stuck_job_report_service.write_log_report(ERROR_TEXT) | ||
end | ||
|
||
def decision_docs_with_errors | ||
DecisionDocument.where("error ILIKE ?", "%#{ERROR_TEXT}%") | ||
end | ||
|
||
def validate_epe(epe) | ||
epe_code = epe&.code&.slice(0, 3) | ||
EPECODES.include?(epe_code) && epe&.established_at.present? | ||
end | ||
|
||
private | ||
|
||
# :reek:FeatureEnvy | ||
def resolve_error_on_records(object_type, epes_array) | ||
ActiveRecord::Base.transaction do | ||
if !epes_array.include?(false) | ||
object_type.clear_error! | ||
end | ||
rescue StandardError => error | ||
log_error(error) | ||
stuck_job_report_service.append_errors(object_type.class.name, object_type.id, error) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
class DtaScCreationFailedFixJob < CaseflowJob | ||
ERROR_TEXT = "DTA SC Creation Failed" | ||
|
||
# :reek:FeatureEnvy | ||
def perform | ||
stuck_job_report_service = StuckJobReportService.new | ||
return if hlrs_with_errors.blank? | ||
|
||
stuck_job_report_service.append_record_count(hlrs_with_errors.count, ERROR_TEXT) | ||
|
||
hlrs_with_errors.each do |hlr| | ||
next unless SupplementalClaim.find_by( | ||
decision_review_remanded_id: hlr.id, | ||
decision_review_remanded_type: "HigherLevelReview" | ||
) | ||
|
||
stuck_job_report_service.append_single_record(hlr.class.name, hlr.id) | ||
|
||
ActiveRecord::Base.transaction do | ||
hlr.clear_error! | ||
rescue StandardError => error | ||
log_error(error) | ||
stuck_job_report_service.append_error(hlr.class.name, hlr.id, error) | ||
end | ||
end | ||
|
||
stuck_job_report_service.append_record_count(hlrs_with_errors.count, ERROR_TEXT) | ||
stuck_job_report_service.write_log_report(ERROR_TEXT) | ||
end | ||
|
||
def hlrs_with_errors | ||
HigherLevelReview.where("establishment_error ILIKE ?", "%#{ERROR_TEXT}%") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class ScDtaForAppealFixJob < CaseflowJob | ||
ERRORTEXT = "Can't create a SC DTA for appeal" | ||
|
||
def records_with_errors | ||
DecisionDocument.where("error ILIKE ?", "%#{ERRORTEXT}%") | ||
end | ||
|
||
def sc_dta_for_appeal_fix | ||
stuck_job_report_service = StuckJobReportService.new | ||
return if records_with_errors.blank? | ||
|
||
# count of records with errors before fix | ||
stuck_job_report_service.append_record_count(records_with_errors.count, ERRORTEXT) | ||
|
||
records_with_errors.each do |decision_doc| | ||
claimant = decision_doc.appeal.claimant | ||
|
||
next unless claimant.payee_code.nil? | ||
|
||
if claimant.type == "VeteranClaimant" | ||
claimant.update!(payee_code: "00") | ||
elsif claimant.type == "DependentClaimant" | ||
claimant.update!(payee_code: "10") | ||
end | ||
stuck_job_report_service.append_single_record(decision_doc.class.name, decision_doc.id) | ||
clear_error_on_record(decision_doc) | ||
end | ||
|
||
# record count with errors after fix | ||
stuck_job_report_service.append_record_count(records_with_errors.count, ERRORTEXT) | ||
stuck_job_report_service.write_log_report(ERRORTEXT) | ||
end | ||
|
||
# :reek:FeatureEnvy | ||
def clear_error_on_record(decision_doc) | ||
ActiveRecord::Base.transaction do | ||
decision_doc.clear_error! | ||
rescue StandardError => error | ||
log_error(error) | ||
stuck_job_report_service.append_errors(decision_doc.class.name, decision_doc.id, error) | ||
end | ||
end | ||
end |
Oops, something went wrong.