From 771933e49e8b34258dd34e0cc7e993b3352ea04a Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Tue, 17 Dec 2024 12:49:56 +0000 Subject: [PATCH] Fix N+1 issue in seeds This fixes an N+1 issue in the seeds that is raised now that strict loading has been enabled globally. --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 161cd6d9e..dd4b36e62 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -232,7 +232,7 @@ def create_patients(organisation) end def create_imports(user, organisation) - programme = organisation.programmes.find_by(type: "hpv") + programme = organisation.programmes.includes(:sessions).find_by(type: "hpv") %i[pending invalid processed].each do |status| FactoryBot.create(