mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-09 23:06:06 +00:00
This totally removes the following N+1 query from the GET /shops request
```sql
SELECT "spree_properties".* FROM "spree_properties"
INNER JOIN "producer_properties"
ON "spree_properties"."id" = "producer_properties"."property_id"
WHERE "producer_properties"."producer_id" = 17
ORDER BY producer_properties.position;
```
The producer properties of the corresponding enterprises are now loaded
in a single query fired from the controller.
14 lines
247 B
Ruby
14 lines
247 B
Ruby
class ShopsController < BaseController
|
|
layout 'darkswarm'
|
|
|
|
before_filter :enable_embedded_shopfront
|
|
|
|
def index
|
|
@enterprises = Enterprise
|
|
.activated
|
|
.includes(address: :state)
|
|
.includes(:properties)
|
|
.all
|
|
end
|
|
end
|