mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Style Rails/WhereRange
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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') }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user