Last active
August 29, 2015 14:14
-
-
Save simmsy/a6b94cd5ca802a0bc9e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://github.com/spree/spree/blob/master/core/app/models/spree/stock/coordinator.rb#L32:L40 | |
def build_packages(packages = Array.new) | |
StockLocation.active.each do |stock_location| | |
next unless stock_location.stock_items.where(:variant_id => inventory_units.map(&:variant_id).uniq).exists? | |
packer = build_packer(stock_location, inventory_units) | |
packages += packer.packages | |
end | |
packages | |
end | |
# refactored to | |
def build_packages(packages = Array.new) | |
# OR StockLocation.for_variant_ids(inventory_units.map(&:variant_id).uniq) | |
StockLocation.active.joins(:stock_items).merge(StockItems.where(:variant_id => inventory_units.map(&:variant_id).uniq).each do |stock_location| | |
packer = build_packer(stock_location, inventory_units) | |
packages += packer.packages | |
end | |
packages | |
end |
Yes mate, add to core please
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To summarize and tidy up this would be what we'd need:
Do you want me to do this directly in our customized version of Spree or do it against master and open a PR then backport to ours?