PeriodicCounter =============== Maintains period fields on any counter column in your database Requirements ------------
sudo gem install periodic_counterCreate columns -------------- You should already have a counter column defined that is being incremented by something (let's call the column X). Define period columns using this format:
X\_last\_week
or X\_last\_6\_hours
.
The period name should follow the format of [ActiveSupport's time extensions](http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/Time.html).
Also add an X_data
varchar column with a length of 2048.
Create configuration
--------------------
Create a file, config/counters.yml
:
my_table_name: - my_counterThe 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