mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Return early (before hitting the DB) in complex product list rendering if we already know the order cycle is closed
This commit is contained in:
@@ -6,6 +6,8 @@ module Api
|
||||
skip_authorization_check
|
||||
|
||||
def products
|
||||
render_no_products unless order_cycle.open?
|
||||
|
||||
products = ProductsRenderer.new(
|
||||
distributor,
|
||||
order_cycle,
|
||||
@@ -15,7 +17,7 @@ module Api
|
||||
|
||||
render json: products
|
||||
rescue ProductsRenderer::NoProducts
|
||||
render status: :not_found, json: ''
|
||||
render_no_products
|
||||
end
|
||||
|
||||
def taxons
|
||||
@@ -35,6 +37,10 @@ module Api
|
||||
|
||||
private
|
||||
|
||||
def render_no_products
|
||||
render status: :not_found, json: ''
|
||||
end
|
||||
|
||||
def product_properties
|
||||
Spree::Property.
|
||||
joins(:products).
|
||||
|
||||
Reference in New Issue
Block a user