Cache distributor

This commit is contained in:
David Cook
2024-08-14 17:26:37 +10:00
parent eb547f4861
commit ffaf1b4ea0
2 changed files with 2 additions and 2 deletions

View File

@@ -42,7 +42,7 @@ module OpenFoodNetwork
end
def distributor
Enterprise.find params[:distributor_id]
@distributor ||= Enterprise.find params[:distributor_id]
end
def scope_to_schedule

View File

@@ -66,7 +66,7 @@ RSpec.describe OpenFoodNetwork::ScopeVariantsForSearch do
it "returns all products distributed through that distributor" do
expect{ result }.to query_database [
"Enterprise Load", "Enterprise Load", "Enterprise Load", # loads same enterprise three times
"Enterprise Load",
"VariantOverride Load",
"SQL"
]