Commit 17f8ea6e by ivan Lan

Improve sql in snapshot

parent cd3c849a
...@@ -39,20 +39,8 @@ module Shotengai ...@@ -39,20 +39,8 @@ module Shotengai
belongs_to :shotengai_cart, foreign_key: :shotengai_order_id, belongs_to :shotengai_cart, foreign_key: :shotengai_order_id,
class_name: 'Shotengai::Cart', optional: true, touch: true class_name: 'Shotengai::Cart', optional: true, touch: true
scope :in_order, ->{ scope :in_order, -> { joins(:shotengai_order).where.not(shotengai_orders: { status: 'cart'}) }
joins(" scope :in_cart, -> { joins(:shotengai_order).where(shotengai_orders: { status: 'cart'}) }
INNER JOIN shotengai_orders ON
shotengai_snapshots.shotengai_order_id = shotengai_orders.id AND
shotengai_orders.status <> 'cart'
")
}
scope :in_cart, ->{
joins("
INNER JOIN shotengai_orders ON
shotengai_snapshots.shotengai_order_id = shotengai_orders.id AND
shotengai_orders.status = 'cart'
")
}
class << self class << self
def inherited subclass def inherited subclass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment