ustream / openduty

An open source Alerting and incident escalation tool
MIT License
788 stars 188 forks source link

Missing UI element for Recurring Schedules #56

Open krutaw opened 8 years ago

krutaw commented 8 years ago

The recurring schedule functionality exists, however, there's no UI elements to inject the necessary values into the database. I was able to get recurring schedules working by manually injecting values into the openduty.schedule_rule table with values that I was able to glean from this page: https://github.com/schacon/django-schedule/blob/master/schedule/models.py. It would be nice to be able to manage this via the UI to avoid having to inject values into the database directly.

sofixa commented 7 years ago

Which part of the configuration are you referring to? I remember it took me some time(i think i had to run some script which came with the library which provided basic recurring rules, like daily, weekly, etc.), but i now have some rules that work.

krutaw commented 7 years ago

@sofixa Exactly my point, you had to run some script to make it work. This should be an element within the UI, and it's not quite there yet.

amartorelli commented 7 years ago

I think I'm having the same issue, what are the values you added to the db? I'm trying to make it recurring so that each user is on call every other week.

krutaw commented 7 years ago

The way I found the settings was to look through the requirements that actually provided the functionality (django-scheduler.) Unfortunately, the documentation isn't great, but it's a start. The way I found it was to search the django-scheduler project for how it set it's rules. Turns out, it uses python-dateutil to define the recurrence settings. You can find the documentation here:

http://labix.org/python-dateutil#head-470fa22b2db72000d7abe698a5783a46b0731b57

So, you can either set the rules in the /admin portal (using a super user) or you can make the changes in the database directly (it's in the schedule_rule table.)

Unfortunately, when you set the frequency, you have to be careful in how you do it. The django-scheduler sets the recurrence based on the beginning day of the recurrence, not the entire set. So if you set a single day, and set every other week, it'll show up in the calendar as the entire week but the actual recurrence will only WORK on the first day of the recurrence.

Just for posterity sake, here's a couple of examples (including yours):

The Name/Description can be anything.

EXAMPLE 1 Example for having someone to be on-call for 7 days every other week:

The recurrence rule would look like this:
Name: Every other week Description: Every other week Frequency: WEEKLY Params: interval:2;byweekday:0,1,2,3,4,5,6;

In the calendar in OpenDuty, set the calendar entry only for a single day (at the beginning of the 7 day shift and set the recurrence to the "Every other week" rule.

The result will be a schedule that repeats every other week and consumes 7 days each time it recurs.

EXAMPLE 1

EXAMPLE 2 Example for weekdays every week.

The recurrence rule would look like this:
Name: Weekdays only Description: Weekdays only Frequency: DAILY Params: byweekday:0,1,2,3,4;

In the calendar in OpenDuty, set the calendar entry only for a single day (on a Monday and set the recurrence to the "Weekdays only" rule.

The result will be a schedule that repeats on weekdays only, leaving the weekends free.

EXAMPLE 2