Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 4b41800e35
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (28 sloc) 1.014 kB

PeriodicCounter

Maintains period fields on any counter column in your database

Requirements

sudo gem install periodic_template

Create columns

For every counter column (X), you should also have a X_computed_at datetime column.

To define period columns, use this format: X_last_1_week or X_last_6_hours.

The name the period column should follow the format of ActiveSupport's time extensions:

http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/Time.html

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
Jump to Line
Something went wrong with that request. Please try again.