Created
December 23, 2019 12:23
-
-
Save swallowstalker/acc77fcbfd94c2f78c0853344b03ba10 to your computer and use it in GitHub Desktop.
Match lancelot stock > 0 with product data
This file contains 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
ProductSkuWarehouseStock.where('available_qty', '>', 0).where.not(warehouse_id: 81).find_in_batches(batch_size: 500) do |stocks| | |
stocks.each do |stock| | |
p_list_inactive = Product.where(sku_id: stock[:product_sku_id], state: 0).pluck(:id) | |
p_list_active = Product.where(sku_id: stock[:product_sku_id], state: 1).pluck(:id) | |
if p_list_active.size == 0 | |
puts "For SKU ID #{stock[:product_sku_id]}, warehouse ID: #{stock[:warehouse_id]} found inactive product ID: #{p_list_inactive}" | |
end | |
if p_list_inactive.size == 0 | |
puts "For SKU ID #{stock[:product_sku_id]}, warehouse ID: #{stock[:warehouse_id]} inactive product not found" | |
end | |
if p_list_active.size > 1 | |
puts "For SKU ID #{stock[:product_sku_id]}, warehouse ID: #{stock[:warehouse_id]} found multiple active product: #{p_list_active}" | |
end | |
end | |
sleep(0.1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment