Closed danielpclark closed 5 years ago
Thanks @danielpclark for sharing this. A few thoughts:
There is an accepted standard for handling recurring events called rrule. There are libraries in both ruby & javascript built on top of it. I feel strongly that we should build our solution around this standard as I believe there many people who have gone before us to solve this very problem. Here's a few resources to check out:
Further reading, I found this discussion on Reddit where some folks were discussing the complexities of recurring events with no end date: https://www.reddit.com/r/PostgreSQL/comments/3d9414/how_to_create_a_calendar_with_recurring_events_in/
Thanks @benjaminwood
Looking into rrule I've found the gem by Square Inc. called ruby-rrule which is a minimalist library for expanding RRULEs, with a goal of being fully compliant with iCalendar spec.
Being
we may want to consider this gem. Between the JS library you've shown here handling the input data from the front end and the output to display I think a minimalist backend for it would be quite acceptable. Rails already handles plenty of date comparison options as is.
Cool, I hadn't seen ruby-rrule. I like that it is minimalist and that it is from square. It is comparatively very young hand has very few contributors. However, I think it'd be easy to replace with one of the other tools if it turned out to be too immature for our production use. I'm always in favor of choosing the lighter weight tool until it isn't practical.
Let's continue this conversation over on #7.
From our discussion I would like to put into writing for further discussion how we might go about implementing the logic of the calendar system in the database. This is by no means the final say on how it will be done, it is merely to provide clarity and discussion in moving forward.
Proposal
1) Database logic should be centered around weeks 2) Weeks can be a pattern of all weeks moving forward with a start date and no end date provided 3) Additional week entries per person can be provided for additional availability with start and end dates given for that week (e.g. Add a single Wednesday for availability in the third week of July) 4) Block out dates are a separate entry in the system 5) Week logic can be an array such as
[None, None, 8..16, None, None, 10..18, None]
(psuedo codeas ranges should probably reflect quarter hours rather then just 24 hours) … imagine this example is a Sunday through Saturday array filter range. Since shifts is the time measurement — 0 through 24 should be acceptable as a range 6) Selecting available persons in the database would be something like (psudo code): select persons from office where within availability.start_date and availability.end_date has specific-day-entry where not None and fully covers opportunity-range and persons has no entry conflicting entry in block-out-datesThese are just some of the basics for the proposal and all changes and input are more than welcome.