From 853fbf2c4ae073f9f7ff92e5ed95bce1f7983eeb Mon Sep 17 00:00:00 2001 From: Toby Privett Date: Wed, 13 Nov 2024 11:02:42 +0000 Subject: [PATCH] Eager load location#suppliers to improve performance - When a supplier_id was not provided, there was no eager loading. --- app/services/locations/finder.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/locations/finder.rb b/app/services/locations/finder.rb index 23323afb6..83ea15c2e 100644 --- a/app/services/locations/finder.rb +++ b/app/services/locations/finder.rb @@ -58,6 +58,8 @@ def apply_nomis_agency_filters(scope) end def apply_supplier_filters(scope) + scope = scope.includes(:suppliers) + return scope unless filter_params.key?(:supplier_id) scope = scope.includes(:suppliers).where(suppliers: { id: split_params(:supplier_id) })