Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Cache query to fetch Price Lists (#13443)

Damian Legawiecae1b3ab01399
diff --git a/core/app/models/spree/price_list.rb b/core/app/models/spree/price_list.rb
index c60cd4fac2..291c7d0865 100644
--- a/core/app/models/spree/price_list.rb
+++ b/core/app/models/spree/price_list.rb
@@ -44,7 +44,8 @@ module Spree
scope :for_store, ->(store) { where(store: store) }
scope :current, lambda { |timezone = nil|
timezone ||= Rails.application.config.time_zone
- current_time = Time.current.in_time_zone(timezone)
+ # Round to beginning of minute to enable Rails query caching
+ current_time = Time.current.in_time_zone(timezone).beginning_of_minute
where('starts_at IS NULL OR starts_at <= ?', current_time)
.where('ends_at IS NULL OR ends_at >= ?', current_time)
}