I need to model the availability of persons by hours by weekday into
an indefinite future, for example, ‘person X is available Mondays
between 9 and 5pm until August 31, 2013.’
I’m stuck trying to figure out how to store this data to support a
query like ‘find all persons available on March 26 between 12 and
It feels like the only solution is to write EVERY interval implied by
the weekly availability specified, but that seems like it will be a
PITA when the availability is changed – will I need to rewrite every
date-time I stored, when, say some person X’s availability is changed
from mondays to tuesdays and sundays, etc.?
Any suggestions on strategies or references to gems for this?
(Below follows a rough modeling.)
sunday (has_many HoursIntervals)
stop (date-time, can be null)