You've already forked oncall
mirror of
https://github.com/linkedin/oncall.git
synced 2025-11-29 23:38:17 +02:00
Group schedule events by role as well as chronologically (#218)
Break ties based on roles
This commit is contained in:
committed by
Joe Gillotti
parent
c98962d7b6
commit
c05869581d
@@ -326,8 +326,8 @@ class Scheduler(object):
|
||||
self.set_last_epoch(schedule['id'], last_epoch, cursor)
|
||||
|
||||
# Create events in the db, associating a user to them
|
||||
# Iterate through events in order of start time to properly assign users
|
||||
for schedule, epoch in sorted(events, key=lambda x: min(ev['start'] for ev in x[1])):
|
||||
# Iterate through events in order of (start time, role) to properly assign users
|
||||
for schedule, epoch in sorted(events, key=lambda x: (min(ev['start'] for ev in x[1]), x[0]['role_id'])):
|
||||
user_id = self.find_next_user_id(schedule, epoch, cursor)
|
||||
if not user_id:
|
||||
logger.info('Failed to find available user')
|
||||
|
||||
Reference in New Issue
Block a user