Skip to content

Commit

Permalink
89790: Populate metadata for DR SavedClaim records (#18026)
Browse files Browse the repository at this point in the history
* 89790: Populate metadata for DR SavedClaim records

* DuplicateMethodCall changes
  • Loading branch information
dfong-adh authored Aug 15, 2024
1 parent c536990 commit 6e556f1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 7 deletions.
15 changes: 13 additions & 2 deletions app/sidekiq/decision_review/saved_claim_hlr_status_updater_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions app/sidekiq/decision_review/saved_claim_nod_status_updater_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 13 additions & 3 deletions app/sidekiq/decision_review/saved_claim_sc_status_updater_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e556f1

Please sign in to comment.