diff --git a/app/models/state_file_archived_intake.rb b/app/models/state_file_archived_intake.rb index abd65ec9cd..c16f90e3f4 100644 --- a/app/models/state_file_archived_intake.rb +++ b/app/models/state_file_archived_intake.rb @@ -30,6 +30,8 @@ class StateFileArchivedIntake < ApplicationRecord has_many :state_file_archived_intake_requests, class_name: 'StateFileArchivedIntakeRequest' enum contact_preference: { unfilled: 0, email: 1, text: 2 }, _prefix: :contact_preference + scope :for_pya, -> { where.not(hashed_ssn: nil) } + before_create :populate_fake_addresses def full_address address_parts = [mailing_street, mailing_apartment, mailing_city, mailing_state, mailing_zip] diff --git a/scripts/copy_to_new_s3_bucket.rb b/scripts/copy_to_new_s3_bucket.rb index 45e4b99757..d7f10fb7c1 100755 --- a/scripts/copy_to_new_s3_bucket.rb +++ b/scripts/copy_to_new_s3_bucket.rb @@ -26,7 +26,7 @@ def copy intakes_without_keys = [] # Default batch 1000 https://apidock.com/rails/ActiveRecord/Batches/find_in_batches - StateFileArchivedIntake.find_in_batches.with_index do |intakes, batch| + StateFileArchivedIntake.for_pya.find_in_batches.with_index do |intakes, batch| say "Processing group ##{batch}..." intakes.each do |intake| diff --git a/spec/models/state_file_archived_intake_spec.rb b/spec/models/state_file_archived_intake_spec.rb index b65557ac17..74d8b28e7b 100644 --- a/spec/models/state_file_archived_intake_spec.rb +++ b/spec/models/state_file_archived_intake_spec.rb @@ -26,6 +26,14 @@ require 'rails_helper' RSpec.describe StateFileArchivedIntake, type: :model do + describe ".for_pya" do + let!(:state_file_archived_intake_with_ssn) { create :state_file_archived_intake } + let!(:state_file_archived_intake_without_ssn) { create :state_file_archived_intake, hashed_ssn: nil } + it "filters out records without a hashed_ssn" do + expect(described_class.for_pya.count).to be 1 + end + end + describe "#increment_failed_attempts" do let!(:state_file_archived_intake) { create :state_file_archived_intake, failed_attempts: 1 } it "locks access when failed attempts is incremented to 2" do