Skip to content

Commit

Permalink
Extract named scope
Browse files Browse the repository at this point in the history
PR feedback suggestion from Steve
  • Loading branch information
rjlynch committed Jul 26, 2024
1 parent 179f5e8 commit 2fb4a54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class Claim < ApplicationRecord
scope :unassigned, -> { where(assigned_to_id: nil) }
scope :current_academic_year, -> { by_academic_year(AcademicYear.current) }
scope :failed_bank_validation, -> { where(hmrc_bank_validation_succeeded: false) }
scope :unscrubbed, -> { where(personal_data_removed_at: nil) }

scope :with_same_claimant, ->(claim) do
CLAIMANT_MATCHING_ATTRIBUTES.reduce(where.not(id: claim.id)) do |scope, attr|
Expand Down
4 changes: 2 additions & 2 deletions app/models/policies/claim_personal_data_scrubber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class ClaimPersonalDataScrubber

def scrub_completed_claims
old_rejected_claims
.where(personal_data_removed_at: nil)
.unscrubbed
.includes(:amendments, :journey_session).each do |claim|
Claim::Scrubber.scrub!(claim, self.class::PERSONAL_DATA_ATTRIBUTES_TO_DELETE)
end

old_paid_claims
.where(personal_data_removed_at: nil)
.unscrubbed
.includes(:amendments, :journey_session).each do |claim|
Claim::Scrubber.scrub!(claim, self.class::PERSONAL_DATA_ATTRIBUTES_TO_DELETE)
end
Expand Down

0 comments on commit 2fb4a54

Please sign in to comment.