I want to create a rake task that will run automatically every seven days (sunday at midnight), that will analyse a weeks worth of data (at max 20,000 records per week).
An Outlet has_many :monitorings
A Monitoring belongs_to :outlet
I want to check if at the end of the week an outlet has had a minimum of 4 records created. If not, I want a record to be created inside of the DB in a table called unmonitored.
The record should contain the the number of times it has been monitored and the week start and end dates.
To run a rake task periodically, you can use bare cron jobs or a nice ruby wrapper, Whenever.
Take a look: