Skip to content

Commit

Permalink
Fix DB query timeout in Duplicate SSN Report (#11284)
Browse files Browse the repository at this point in the history
* Slice up the list instead of one giant query

- Follow-up, similar to #9818

changelog: Internal, Reporting, Fix database query timeout in report
  • Loading branch information
zachmargolis authored Sep 25, 2024
1 parent faea79d commit 52a6e86
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/jobs/reports/duplicate_ssn_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ def report_body

ssn_signatures = todays_profiles.map(&:ssn_signature).uniq

profiles_connected_by_ssn = Profile.
includes(:user).
where(ssn_signature: ssn_signatures).
to_a
profiles_connected_by_ssn = ssn_signatures.each_slice(1000).flat_map do |ssn_signature_slice|
Profile.
includes(:user).
where(ssn_signature: ssn_signature_slice).
to_a
end

profiles_connected_by_ssn.sort_by!(&:id).reverse!

Expand Down

0 comments on commit 52a6e86

Please sign in to comment.