lib/subj_models/nomenclature.rb in subj_models-0.5.8 vs lib/subj_models/nomenclature.rb in subj_models-0.5.9
- old
+ new
@@ -42,11 +42,10 @@
scope :is_stock, -> (condition) do
nomenclature_prices_join.joins("LEFT OUTER JOIN qualities ON qualities.id = nomenclature_prices.quality_id").where("qualities.is_stock" => condition).uniq
end
scope :bought_together_external_id, -> (ids) do
- order_ids = Order.joins(order_items: [nomenclature_variety: :nomenclature]).where("nomenclatures.external_id IN (?)", ids).uniq.pluck(:id)
- Nomenclature.joins(nomenclature_varieties: [order_items: :order]).where("orders.id" => order_ids).order(:id).uniq
+ joins(:bought_together_related_nomenclature).where(bought_together_related_nomenclature: {external_id: ids }).uniq
end
scope :is_available, -> (params) do
is_available = params.first
return all unless is_available == 'true'
\ No newline at end of file