godaddy/spree — pull request #18 by BMorearty (2014-07-17 22:23:02+00:00)
Title: Improve api performance

Refactor BaseController#product_scope to allow subclasses
to override the associations that are eager-loaded from a product.
In doing so, removed two associations that were eager-loaded
but never referenced (product.properties, variant.prices).

In Product#total_on_hand, don't load and instantiate all the
variants if all we need to know is whether any of them
track inventory. And don't load all the stock_items to sum their
counts on hand. (Fix to 368b89786).

Speeds up the API (e.g., /api/products, /api/products/1) by a factor of 8
for a product with 1,000 variants.

See also spree/spree#5008.