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.

Avoid extra query when invalidating selected shipping rates cache

Karol Szusterbbe7b2590868
diff --git a/core/app/models/spree/shipment.rb b/core/app/models/spree/shipment.rb
index aa048b409f..a297200334 100644
--- a/core/app/models/spree/shipment.rb
+++ b/core/app/models/spree/shipment.rb
@@ -249,8 +249,8 @@ module Spree
end
def selected_shipping_rate_id=(id)
- shipping_rates.update_all(selected: false)
- shipping_rates.touch_all # Bust cache dependent on "updated_at" timestamp
+ # Explicitly updates the timestamp in order to bust cache dependent on "updated_at"
+ shipping_rates.update_all(selected: false, updated_at: Time.current)
shipping_rates.update(id, selected: true)
save!
end