The final schedule object from PagerDuty containing rendered schedule entries
The IANA timezone identifier to use for OOH calculations across all entries
A Record mapping user IDs to OnCallUser objects with their consolidated on-call periods
Key behaviours:
Algorithm:
const finalSchedule = {
rendered_schedule_entries: [
{ start: new Date('2024-01-01T18:00:00Z'), end: new Date('2024-01-02T09:00:00Z'),
user: { id: 'USER1', summary: 'John Doe' } },
{ start: new Date('2024-01-02T18:00:00Z'), end: new Date('2024-01-03T09:00:00Z'),
user: { id: 'USER1', summary: 'John Doe' } },
{ start: new Date('2024-01-03T18:00:00Z'), end: new Date('2024-01-04T09:00:00Z'),
user: { id: 'USER2', summary: 'Jane Smith' } }
]
};
const users = extractOnCallUsersFromFinalSchedule(finalSchedule, 'Europe/London');
// Returns: { 'USER1': OnCallUser with 2 periods, 'USER2': OnCallUser with 1 period }
Extracts and consolidates on-call users from a PagerDuty final schedule.
This function processes all schedule entries from a PagerDuty final schedule and creates a dictionary of OnCallUser objects, consolidating multiple time periods for the same user into a single OnCallUser with multiple OnCallPeriods.