From 6e556f1b9e64500a57c0b8499425580d91c31bbe Mon Sep 17 00:00:00 2001 From: dfong-adh <151783381+dfong-adh@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:37:04 -0700 Subject: [PATCH] 89790: Populate metadata for DR SavedClaim records (#18026) * 89790: Populate metadata for DR SavedClaim records * DuplicateMethodCall changes --- .../saved_claim_hlr_status_updater_job.rb | 15 +++++++++++++-- .../saved_claim_nod_status_updater_job.rb | 15 +++++++++++++-- .../saved_claim_sc_status_updater_job.rb | 16 +++++++++++++--- .../saved_claim_hlr_status_updater_job_spec.rb | 4 ++++ .../saved_claim_nod_status_updater_job_spec.rb | 4 ++++ .../saved_claim_sc_status_updater_job_spec.rb | 4 ++++ 6 files changed, 51 insertions(+), 7 deletions(-) diff --git a/app/sidekiq/decision_review/saved_claim_hlr_status_updater_job.rb b/app/sidekiq/decision_review/saved_claim_hlr_status_updater_job.rb index b5054bcdfcf..ff2b1ecc02c 100644 --- a/app/sidekiq/decision_review/saved_claim_hlr_status_updater_job.rb +++ b/app/sidekiq/decision_review/saved_claim_hlr_status_updater_job.rb @@ -19,13 +19,24 @@ def perform higher_level_reviews.each do |hlr| guid = hlr.guid - status = decision_review_service.get_higher_level_review(guid).dig('data', 'attributes', 'status') + response = decision_review_service.get_higher_level_review(guid) + status = response.dig('data', 'attributes', 'status') + attributes = response.dig('data', 'attributes') + + timestamp = DateTime.now + params = { metadata: attributes.to_json, metadata_updated_at: timestamp } if SUCCESSFUL_STATUS.include? status - hlr.update(delete_date: DateTime.now + RETENTION_PERIOD) + params[:delete_date] = timestamp + RETENTION_PERIOD Rails.logger.info("#{self.class.name} updated delete_date", guid:) end + + hlr.update(params) + rescue => e + Rails.logger.error('DecisionReview::SavedClaimHlrStatusUpdaterJob error', { guid:, message: e.message }) end + + nil end private diff --git a/app/sidekiq/decision_review/saved_claim_nod_status_updater_job.rb b/app/sidekiq/decision_review/saved_claim_nod_status_updater_job.rb index d55ce925ac7..c2d69497860 100644 --- a/app/sidekiq/decision_review/saved_claim_nod_status_updater_job.rb +++ b/app/sidekiq/decision_review/saved_claim_nod_status_updater_job.rb @@ -19,13 +19,24 @@ def perform notice_of_disagreements.each do |nod| guid = nod.guid - status = decision_review_service.get_notice_of_disagreement(guid).dig('data', 'attributes', 'status') + response = decision_review_service.get_notice_of_disagreement(guid) + status = response.dig('data', 'attributes', 'status') + attributes = response.dig('data', 'attributes') + + timestamp = DateTime.now + params = { metadata: attributes.to_json, metadata_updated_at: timestamp } if SUCCESSFUL_STATUS.include? status - nod.update(delete_date: DateTime.now + RETENTION_PERIOD) + params[:delete_date] = timestamp + RETENTION_PERIOD Rails.logger.info("#{self.class.name} updated delete_date", guid:) end + + nod.update(params) + rescue => e + Rails.logger.error('DecisionReview::SavedClaimNodStatusUpdaterJob error', { guid:, message: e.message }) end + + nil end private diff --git a/app/sidekiq/decision_review/saved_claim_sc_status_updater_job.rb b/app/sidekiq/decision_review/saved_claim_sc_status_updater_job.rb index 91f607c32f8..f341551c70f 100644 --- a/app/sidekiq/decision_review/saved_claim_sc_status_updater_job.rb +++ b/app/sidekiq/decision_review/saved_claim_sc_status_updater_job.rb @@ -19,14 +19,24 @@ def perform supplemental_claims.each do |sc| guid = sc.guid - status = decision_review_service.get_supplemental_claim(guid).dig('data', 'attributes', 'status') + response = decision_review_service.get_supplemental_claim(guid) + status = response.dig('data', 'attributes', 'status') + attributes = response.dig('data', 'attributes') + + timestamp = DateTime.now + params = { metadata: attributes.to_json, metadata_updated_at: timestamp } - # check status of SC and update delete_date if SUCCESSFUL_STATUS.include? status - sc.update(delete_date: DateTime.now + RETENTION_PERIOD) + params[:delete_date] = timestamp + RETENTION_PERIOD Rails.logger.info("#{self.class.name} updated delete_date", guid:) end + + sc.update(params) + rescue => e + Rails.logger.error('DecisionReview::SavedClaimScStatusUpdaterJob error', { guid:, message: e.message }) end + + nil end private diff --git a/spec/sidekiq/decision_review/saved_claim_hlr_status_updater_job_spec.rb b/spec/sidekiq/decision_review/saved_claim_hlr_status_updater_job_spec.rb index d91a520f608..ceefcd6f093 100644 --- a/spec/sidekiq/decision_review/saved_claim_hlr_status_updater_job_spec.rb +++ b/spec/sidekiq/decision_review/saved_claim_hlr_status_updater_job_spec.rb @@ -56,9 +56,13 @@ claim1 = SavedClaim::HigherLevelReview.find_by(guid: guid1) expect(claim1.delete_date).to eq frozen_time + 59.days + expect(claim1.metadata).to include 'complete' + expect(claim1.metadata_updated_at).to eq frozen_time claim2 = SavedClaim::HigherLevelReview.find_by(guid: guid2) expect(claim2.delete_date).to be_nil + expect(claim2.metadata).to include 'pending' + expect(claim2.metadata_updated_at).to eq frozen_time end end end diff --git a/spec/sidekiq/decision_review/saved_claim_nod_status_updater_job_spec.rb b/spec/sidekiq/decision_review/saved_claim_nod_status_updater_job_spec.rb index 36b16c9a6ed..9465ca510ad 100644 --- a/spec/sidekiq/decision_review/saved_claim_nod_status_updater_job_spec.rb +++ b/spec/sidekiq/decision_review/saved_claim_nod_status_updater_job_spec.rb @@ -56,9 +56,13 @@ claim1 = SavedClaim::NoticeOfDisagreement.find_by(guid: guid1) expect(claim1.delete_date).to eq frozen_time + 59.days + expect(claim1.metadata).to include 'complete' + expect(claim1.metadata_updated_at).to eq frozen_time claim2 = SavedClaim::NoticeOfDisagreement.find_by(guid: guid2) expect(claim2.delete_date).to be_nil + expect(claim2.metadata).to include 'pending' + expect(claim2.metadata_updated_at).to eq frozen_time end end end diff --git a/spec/sidekiq/decision_review/saved_claim_sc_status_updater_job_spec.rb b/spec/sidekiq/decision_review/saved_claim_sc_status_updater_job_spec.rb index f407f23f885..2621c82a44e 100644 --- a/spec/sidekiq/decision_review/saved_claim_sc_status_updater_job_spec.rb +++ b/spec/sidekiq/decision_review/saved_claim_sc_status_updater_job_spec.rb @@ -56,9 +56,13 @@ claim1 = SavedClaim::SupplementalClaim.find_by(guid: guid1) expect(claim1.delete_date).to eq frozen_time + 59.days + expect(claim1.metadata).to include 'complete' + expect(claim1.metadata_updated_at).to eq frozen_time claim2 = SavedClaim::SupplementalClaim.find_by(guid: guid2) expect(claim2.delete_date).to be_nil + expect(claim2.metadata).to include 'pending' + expect(claim2.metadata_updated_at).to eq frozen_time end end end