| Issue 135: | DB littered with CART items | |
| 3 people starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem? 1. Hit /store a bunch of times. 2. See a ton of empty CART orders in the db What is the expected output? What do you see instead? With large volume sites, this probably isn't the best behavior. Perhaps provide a rake maint script to cleanup these empty carts - or figure out a way not to store them in the DB at all. Either solution must respect the issues raised with issue 114
Mar 10, 2009
Project Member
#1
rogerdp...@gmail.com
Mar 10, 2009
That's how the old code used to work and it was causing massive issues when you tried to checkout, then go shop for more items. Removing that method of working is what fixed that nasty bug. Re-creating it is not something I'd like to get into. This should be solved, but in another manner.
Oct 7, 2009
# MAINTENANCE ===============================================================
desc %q\
Hourly maintenance task that should be run on your Substruct site.
Does some housekeeping so the DB is in order.
Remember to pass it the proper RAILS_ENV if running from cron.
\
task :maintain => :environment do
puts "Removing crusty sessions..."
stale = Session.find(:all, :conditions => ["updated_at <= ?", Time.now -
Session::SESSION_TIMEOUT])
stale.each { |s| s.destroy }
puts "Removing carts older than 10 days"
stale_carts = Order.find(:all, :conditions => ["order_status_code_id = ? and
DATE_SUB(curdate(), interval 10 day) > created_on"], 1)
stale_carts.each { |c| c.destroy }
puts "Removing empty carts older than 24 hours"
stale_carts = Order.find(:all, :conditions => ["product_cost = 0 and
order_status_code_id = 1 and DATE_SUB(curdate(), interval 1 d\
ay) > created_on"])
stale_carts.each { |c| c.destroy
end
Dec 6, 2009
FYI, the above method is a bit slow for removing carts. This is a bit better. # Clear out empty CART orders older than a day Order.destroy_all(%Q\ order_status_code_id = 1 AND DATE(created_on) < CURRENT_DATE AND product_code = 0 \)
Aug 28, 2010
Fixed for real with r316 |