Skip to content

Commit 3790856

Browse files
authored
Merge pull request #6593 from NHSDigital/simplify-batching-query-in-patient-status-updater
Simplify batching query in PatientStatusUpdater
2 parents 5c99e16 + 86ddf32 commit 3790856

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

app/lib/patient_status_updater.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ def update_programme_statuses!
4242

4343
merge_patient_scope(Patient::ProgrammeStatus)
4444
.where(academic_year: academic_years)
45-
.includes(
46-
:attendance_record,
47-
:consents,
48-
:patient,
49-
:patient_locations,
50-
:triages,
51-
:vaccination_records,
52-
:parents
53-
)
54-
.find_in_batches do |batch|
45+
.in_batches do |relation|
46+
batch =
47+
relation.includes(
48+
:attendance_record,
49+
:consents,
50+
:patient,
51+
:patient_locations,
52+
:triages,
53+
:vaccination_records,
54+
:parents
55+
).to_a
56+
5557
batch.each(&:assign)
5658

5759
Patient::ProgrammeStatus.import!(

0 commit comments

Comments
 (0)