mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Extract private methods
This commit is contained in:
@@ -16,7 +16,13 @@ class RemoveTransientData
|
||||
Spree::LogEntry.where("created_at < ?", RETENTION_PERIOD).delete_all
|
||||
Session.where("updated_at < ?", RETENTION_PERIOD).delete_all
|
||||
|
||||
# Clear old carts and associated records
|
||||
clear_old_cart_data!
|
||||
clear_line_item_option_values!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clear_old_cart_data!
|
||||
old_carts = Spree::Order.where("state = 'cart' AND updated_at < ?", RETENTION_PERIOD)
|
||||
old_cart_line_items = Spree::LineItem.where(order_id: old_carts)
|
||||
old_cart_adjustments = Spree::Adjustment.where(order_id: old_carts)
|
||||
@@ -24,8 +30,9 @@ class RemoveTransientData
|
||||
old_cart_adjustments.delete_all
|
||||
old_cart_line_items.delete_all
|
||||
old_carts.delete_all
|
||||
end
|
||||
|
||||
# Clear option values for deleted line items
|
||||
def clear_line_item_option_values!
|
||||
ActiveRecord::Base.connection.execute <<-SQL
|
||||
DELETE FROM spree_option_values_line_items
|
||||
WHERE line_item_id IN (
|
||||
|
||||
Reference in New Issue
Block a user