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:
Matt-Yorkley
2020-04-28 13:51:25 +02:00
parent 67a7140642
commit eb7de18298

View File

@@ -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).