Convert Permissions::Order#visible_line_items to a relation with or query

This change looks innocuous but the result of converting this into a nice relation instead of two queries stuck together with the pipe operator (|) can make a huge difference when chaining this into subqueries. The result set is ultimately the same, but the queries can be built without first returning all the ids and then sticking those ids in an array.
This commit is contained in:
Matt-Yorkley
2023-04-28 19:13:22 +01:00
parent 152af5e105
commit dfc651ed2c

View File

@@ -31,9 +31,9 @@ module Permissions
end
def visible_line_items
Spree::LineItem.where(id:
editable_line_items.select(:id) |
produced_line_items.select("spree_line_items.id"))
Spree::LineItem
.where(id: editable_line_items.select(:id))
.or(Spree::LineItem.where(id: produced_line_items.select("spree_line_items.id")))
end
# Any line items that I can edit