PeriodicCounter =============== Maintains period fields on any counter column in your database Requirements ------------
sudo gem install periodic_counter
Create columns -------------- You should already have a counter column (let's call it X) that is being incremented by some external process. Add an X_data varchar column with a length of 2048. Add your periodic counters (all integers): * X\_last\_week * X\_last\_6\_hours * X\_last\_sunday * X\_2\_days\_ago Currently only days of the week and [ActiveSupport's time extensions](http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/Time.html) are supported for time periods. If no digit is present, "1" is assumed. Create configuration -------------------- Create a file, config/counters.yml:
my_table_name:
  - my_counter
The plugin assumes that the config directory also houses your database.yml file. Create cron entry ----------------- Add the following command to your crontab at a period of your choosing:
cd /path/to/your/app && RAILS_ENV=production periodic_counter