My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 135: DB littered with CART items
3 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  subim...@gmail.com
Closed:  Dec 2009


 
Project Member Reported by subim...@gmail.com, Sep 19, 2008
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
I'd suggest just having a cart instance but never actually saving it until an item 
is added to it, either that or never creating and assigning a cart instance until an 
item is added to it [make that before_filter :only => :checkout] or something.
-=r
Mar 10, 2009
Project Member #2 subim...@gmail.com
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.
Mar 10, 2009
Project Member #3 subim...@gmail.com
PS: The current method was chosen to fix bugs -  issue 114 ,  issue 111 
Oct 7, 2009
#4 flyfish...@gmail.com

  # 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
Project Member #5 subim...@gmail.com
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
\)
Dec 25, 2009
Project Member #6 subim...@gmail.com
Fixed in r185
Status: Fixed
Aug 28, 2010
Project Member #7 subim...@gmail.com
Fixed for real with r316

Powered by Google Project Hosting