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
2pm’.
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?
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?
You could expand my ‘relativity’ gem for that.
You would need to:
implement the WeekTime, WeekTimeRange
and WeekTimeRangeArray class
where requested_time_range would be an absolute time range
(e.g. “March 26, 2012 between 12 and 2pm” in your example)
…
saturday …
You have a potential problem here …
What if one of the DayTimeRange s (that’s how I call them) spans
night_shift = DayTimeRange.new(“22:00…06:00”) then your simple
mapping to 7 week days with a start-stop per day will fail.
Availability
start (date-time)
stop (date-time, can be null)
has_one WeeklyTime
HTH,
Peter
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.