From fb504a69eef8e9d1e183b6d347066f04e142faa0 Mon Sep 17 00:00:00 2001 From: Lori Bailey <44073106+elceebee@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:49:08 +0100 Subject: [PATCH] Remove lazy loading for performance --- app/queries/get_applications_to_send_deadline_reminders_to.rb | 2 +- ...et_incomplete_course_choice_applications_ready_to_nudge.rb | 2 +- ...complete_personal_statement_applications_ready_to_nudge.rb | 4 ++-- .../get_incomplete_reference_applications_ready_to_nudge.rb | 2 +- app/queries/get_unsubmitted_applications_ready_to_nudge.rb | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/queries/get_applications_to_send_deadline_reminders_to.rb b/app/queries/get_applications_to_send_deadline_reminders_to.rb index 3a27c508d5c..789c6b9b2fc 100644 --- a/app/queries/get_applications_to_send_deadline_reminders_to.rb +++ b/app/queries/get_applications_to_send_deadline_reminders_to.rb @@ -5,7 +5,7 @@ def self.call def self.deadline_reminder_query ApplicationForm - .includes(:candidate) + .joins(:candidate) .current_cycle .unsubmitted .where.not(candidate: { unsubscribed_from_emails: true }) diff --git a/app/queries/get_incomplete_course_choice_applications_ready_to_nudge.rb b/app/queries/get_incomplete_course_choice_applications_ready_to_nudge.rb index 53c11fe0c8f..0198c98e566 100644 --- a/app/queries/get_incomplete_course_choice_applications_ready_to_nudge.rb +++ b/app/queries/get_incomplete_course_choice_applications_ready_to_nudge.rb @@ -8,7 +8,7 @@ class GetIncompleteCourseChoiceApplicationsReadyToNudge def call ApplicationForm - .includes(:candidate) + .joins(:candidate) .where.not('candidate.submission_blocked': true) .where.not('candidate.account_locked': true) .where.not('candidate.unsubscribed_from_emails': true) diff --git a/app/queries/get_incomplete_personal_statement_applications_ready_to_nudge.rb b/app/queries/get_incomplete_personal_statement_applications_ready_to_nudge.rb index 9b188628279..dbd33003688 100644 --- a/app/queries/get_incomplete_personal_statement_applications_ready_to_nudge.rb +++ b/app/queries/get_incomplete_personal_statement_applications_ready_to_nudge.rb @@ -13,12 +13,12 @@ def call .inactive_since(7.days.ago) .with_completion(COMPLETION_ATTRS) .current_cycle - .includes(:candidate) + .joins(:candidate) .where.not('candidate.submission_blocked': true) .where.not('candidate.account_locked': true) .where.not('candidate.unsubscribed_from_emails': true) .where(INCOMPLETION_ATTRS.map { |attr| "#{attr} = false" }.join(' AND ')) .has_not_received_email(MAILER, MAIL_TEMPLATE) - .includes(:application_choices).where('application_choices.status': 'unsubmitted') + .joins(:application_choices).where('application_choices.status': 'unsubmitted') end end diff --git a/app/queries/get_incomplete_reference_applications_ready_to_nudge.rb b/app/queries/get_incomplete_reference_applications_ready_to_nudge.rb index 283ab188e89..6ffbd641adc 100644 --- a/app/queries/get_incomplete_reference_applications_ready_to_nudge.rb +++ b/app/queries/get_incomplete_reference_applications_ready_to_nudge.rb @@ -10,7 +10,7 @@ def call uk_and_irish = uk_and_irish_names.map { |name| ActiveRecord::Base.connection.quote(name) }.join(',') ApplicationForm - .includes(:candidate) + .joins(:candidate) .where.not('candidate.submission_blocked': true) .where.not('candidate.account_locked': true) .where.not('candidate.unsubscribed_from_emails': true) diff --git a/app/queries/get_unsubmitted_applications_ready_to_nudge.rb b/app/queries/get_unsubmitted_applications_ready_to_nudge.rb index bd8bd67d6ca..4f5ae8e2ba4 100644 --- a/app/queries/get_unsubmitted_applications_ready_to_nudge.rb +++ b/app/queries/get_unsubmitted_applications_ready_to_nudge.rb @@ -15,11 +15,11 @@ def call .with_completion(COMMON_COMPLETION_ATTRS) .current_cycle .has_not_received_email(MAILER, MAIL_TEMPLATE) - .includes(:candidate) + .joins(:candidate) .where.not('candidate.submission_blocked': true) .where.not('candidate.account_locked': true) .where.not('candidate.unsubscribed_from_emails': true) - .includes(:application_choices).where('application_choices.status': 'unsubmitted') + .joins(:application_choices).where('application_choices.status': 'unsubmitted') .and(ApplicationForm .where(science_gcse_completed: true) .or(