I'm building an application that checks when a user needs to change the oil of one of his cars. Here's how it works:
- The user enters the name of his car (e.g. 'Ford Mustang')
- The user enters the time the car will run on one oil change (e.g. 3.months)
- The user saves the car to the database
- Repeat above process for all his other cars. (Yes, it's a wealthy user ;)
Now, when the user comes back to the site he wants to see a list of all his cars that are in need of an oil change. He then changes the oil and updates the 'oil_changed_at' property.
I'm using the following columns for the Car-model:
title:string
oil_changed_at:datetime
oil_expiration_timeframe:integer
My question: What is the preferred way to store this 'oil_expiration_timeframe' and what should my :conditions look like when I want to get a list of all cars that are in need of an oil change?
Keep in mind the oil_expiration_timeframe may vary from a few days to a few years. It will never be less than a day so I think I can just store the amount of days in that field. However, I'm not sure how to combine the integer and datetime in the query.