ice-cube-ruby / ice_cube

Ruby Date Recurrence Library - Allows easy creation of recurrence rules and fast querying
MIT License
2.41k stars 358 forks source link

Suitable for users with different availability times? #306

Closed pjsim closed 8 years ago

pjsim commented 9 years ago

Hi guys, I'm trying to find out if this gem is suitable for a particular use case I have.

I want to set up an availability schedule where users can enter, for each day of the week, what hours of the day they are available and if there will be any exceptions when they are not available at a particular time.

For instance a user will say I am available on Mondays between 7am and 1pm and also between 4pm and 7pm (and so forth for the other days of the week). I also need to add particular exceptions so even if a user says they are free between 7am and 1pm on a Monday they can say I will not be free this particular Monday between 10am and 11am (the start and end times are important)

Is this gem suitable for this case? Looking into it so far it seems to do different availability times for different days of the week I will need to setup a new schedule for each day (would rather avoid this) and also that the exceptions don't support end times. Ideally I would want all this information in a single schedule hash stored on the user and then load that up when I need it.

Thanks

martinstreicher commented 8 years ago

I have this use case in my application. My logic is something like this:

There is also another rub: I run my scheduler every ten minutes or so to pick up jobs that are due. I have to account for the scheduler not running exactly at 9am -- it might run at 9.01am. Typically, setting a duration helps, or here, since you have a window, the scheduler is likely to run at least once in the window of availability.

I could have had exceptions per user, but since a task typically is assigned to a group, I decided to add a little logic just to police the per user availability. (I actually have lots of other rules, too, such as expiries , whether that are recurrence rules for a task, etc.)

So, I guess what I'm saying is, you could create a schedule of availability per user, and then a schedule for your tasks, and both have to agree it is time to actually run something.

avit commented 8 years ago

Sorry for the late reply: if your time slots are the same duration (say, 1 hour appointments) then it could work for this use case, with both a regular schedule (every week at...) or with individual times.

It won't support different durations or regular intervals with breaks in between.