GithubHelp home page GithubHelp logo

nebulab / spree-garbage-cleaner Goto Github PK

View Code? Open in Web Editor NEW
11.0 8.0 17.0 926 KB

A little gem that helps you cleanup old, unneeded data from a Spree database.

License: BSD 3-Clause "New" or "Revised" License

Ruby 100.00%

spree-garbage-cleaner's Introduction

SpreeGarbageCleaner

Build Status Coverage Status Code Climate

This extension cleans your Spree database from unneeded data. When your website grows, it could be useful to delete these old records to improve database performance.

Important notice 1: This extension can delete a lot of stuff from your database. It is thought to be used with some default Spree behaviors so be sure to know what you are doing, expecially if your app has a lot of custom stuff!

Important notice 2: This extension is tested only with the spree_auth_devise extension.

What does this garbage contain?

Incomplete orders

By default incomplete orders are kept even if they are not completed. This extension searches for incomplete orders and deletes them and their dependent association instances:

  • line items
  • payments
  • shipments
  • return authorizations
  • adjustments

Anonymous users

When (not logged in) users begin to add items to cart, an anonymous user is created and associated to the new order. This extension deletes all old anonymous users that have never completed orders.

Installation

Add the gem to your Gemfile:

gem 'spree_garbage_cleaner', :git => 'git://github.com/nebulab/spree-garbage-cleaner.git', :branch => '1-2-stable'

Run bundle:

bundle

Usage

To verify presence of garbage in your database run the stats rake task:

rake db:garbage:stats

To delete garbage from your database run the cleanup rake task:

rake db:garbage:cleanup

Configure the number of days after which records are considered garbage

For each model that collects garbage records you can choose after how many days those records are marked as garbage. Default value is 7 (one week). To change this default value you can run from the rails console:

Spree::GarbageCleaner::Config.set(:cleanup_days_interval, 10)

Setup a cronjob to cleanup garbage

You can setup a cronjob that periodically runs the cleanup rake task for you. Just add the whenever gem to your Gemfile and this to your config/schedule.rb:

every 1.day, :at => '5:00 am' do
  rake "-s db:garbage:cleanup"
end

Testing

Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.

$ bundle
$ bundle exec rake test_app
$ bundle exec rspec spec

Copyright (c) 2012 NebuLab, released under the New BSD License

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.