Skip to content

Commit

Permalink
Optimise application lookup (#1750)
Browse files Browse the repository at this point in the history
Preload the matching applications in NPQ reg instead of finding on each iteration.
  • Loading branch information
ethax-ross authored Oct 1, 2024
1 parent c89f2fe commit b5bd31e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/services/migration/migrators/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ def records_per_worker
def call
run_once { report_applications_not_in_ecf_as_failures }

applications_by_ecf_id = ::Application.where(ecf_id: self.class.ecf_npq_applications.pluck(:id)).index_by(&:ecf_id)

migrate(self.class.ecf_npq_applications) do |ecf_npq_application|
application = ::Application.find_by!(ecf_id: ecf_npq_application.id)
application = applications_by_ecf_id[ecf_npq_application.id]

raise ActiveRecord::RecordNotFound, "Couldn't find Application" unless application

ensure_relationships_are_consistent!(ecf_npq_application, application)

Expand Down

0 comments on commit b5bd31e

Please sign in to comment.