Make /api/orders N+1 free

With the help of the bullet gem, and since we remove a couple of N+1s
already, remove them all was just a few keystrokes away. This commits
gets us from 42 SQL queries to 17, and 364.5ms to 253.9ms on my machine
where I just have the sample data's orders. As usual, this will have
a much bigger impact in scenarios with more data.
This commit is contained in:
Pau Perez
2021-02-23 17:13:03 +01:00
committed by Andy Brett
parent 20a7f2f24e
commit 116109c63d

View File

@@ -14,7 +14,7 @@ class SearchOrders
def fetch_orders
@search = search_query.
includes(:payments, :subscription).
includes(:payments, :subscription, :shipments, :bill_address, :distributor, :order_cycle).
ransack(params[:q])
return paginated_results if using_pagination?