diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 7cfc71c9a6..69c89d673f 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -32,6 +32,6 @@ class Invoice < ApplicationRecord end def previous_invoice - order.invoices.where("id < ?", id).first + order.invoices.where(id: ...id).first end end diff --git a/app/models/order_cycle.rb b/app/models/order_cycle.rb index f87e850fdd..e5c41974c5 100644 --- a/app/models/order_cycle.rb +++ b/app/models/order_cycle.rb @@ -53,7 +53,7 @@ class OrderCycle < ApplicationRecord Time.zone.now, Time.zone.now) } - scope :active_or_complete, lambda { where('order_cycles.orders_open_at <= ?', Time.zone.now) } + scope :active_or_complete, lambda { where(order_cycles: { orders_open_at: ..Time.zone.now }) } scope :inactive, lambda { where('order_cycles.orders_open_at > ? OR order_cycles.orders_close_at < ?', Time.zone.now, @@ -64,8 +64,8 @@ class OrderCycle < ApplicationRecord where('order_cycles.orders_close_at > ? OR order_cycles.orders_close_at IS NULL', Time.zone.now) } scope :closed, lambda { - where('order_cycles.orders_close_at < ?', - Time.zone.now).order("order_cycles.orders_close_at DESC") + where(order_cycles: { orders_close_at: ...Time.zone.now }) + .order("order_cycles.orders_close_at DESC") } scope :unprocessed, -> { where(processed_at: nil) } scope :undated, -> { where('order_cycles.orders_open_at IS NULL OR orders_close_at IS NULL') } diff --git a/engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb b/engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb index e906a0ed16..0b4975e14c 100644 --- a/engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb +++ b/engines/order_management/app/services/order_management/subscriptions/proxy_order_syncer.rb @@ -90,9 +90,8 @@ module OrderManagement end def in_range_order_cycles - order_cycles.where("orders_close_at >= ? AND orders_close_at <= ?", - begins_at, - ends_at || 100.years.from_now) + ends_at_or_limit = ends_at || 100.years.from_now + order_cycles.where(orders_close_at: begins_at..ends_at_or_limit ) end end end diff --git a/lib/tasks/data/remove_transient_data.rb b/lib/tasks/data/remove_transient_data.rb index ffe136cd08..95573c1a0a 100644 --- a/lib/tasks/data/remove_transient_data.rb +++ b/lib/tasks/data/remove_transient_data.rb @@ -18,9 +18,9 @@ class RemoveTransientData def call Rails.logger.info("#{self.class.name}: processing") - Spree::StateChange.where("created_at < ?", expiration_date).delete_all - Spree::LogEntry.where("created_at < ?", expiration_date).delete_all - Session.where("updated_at < ?", expiration_date).delete_all + Spree::StateChange.where(created_at: ...expiration_date).delete_all + Spree::LogEntry.where(created_at: ...expiration_date).delete_all + Session.where(updated_at: ...expiration_date).delete_all clear_old_cart_data! end