From 985f1a39e3b8bd1a5464d1eff2de9895f5ff35b3 Mon Sep 17 00:00:00 2001 From: elasticspoon Date: Mon, 8 Apr 2024 01:39:06 -0400 Subject: [PATCH] fix: improved query --- app/models/case_court_report_context.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/case_court_report_context.rb b/app/models/case_court_report_context.rb index 2868cd4557..122ccabb23 100644 --- a/app/models/case_court_report_context.rb +++ b/app/models/case_court_report_context.rb @@ -57,8 +57,8 @@ def case_orders(orders) end def filtered_interviewees - # this query is slow - CaseContactContactType.includes(:case_contact, :contact_type) + CaseContactContactType + .joins(:contact_type, case_contact: :casa_case) .where("case_contacts.casa_case_id": @casa_case.id) .where("case_contacts.occurred_at": @date_range) end