forked from linkedin/oncall
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New multi-team scheduler (linkedin#415)
* allow editing info for api managed teams * add a team description field [MYSQL SCHEMA CHANGE] * modify tests [MYSQL SCHEMA CHANGE] * add multi-team scheduler * use py image * add changelog * py img * fix typo * add test
- Loading branch information
1 parent
88ae866
commit ce3bd26
Showing
8 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "2.1.5" | ||
__version__ = "2.1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from . import default | ||
|
||
|
||
class Scheduler(default.Scheduler): | ||
# same as no-skip-matching | ||
def create_events(self, team_id, schedule_id, user_id, events, role_id, cursor, table_name='event', skip_match=True): | ||
super(Scheduler, self).create_events(team_id, schedule_id, user_id, events, role_id, cursor, table_name, skip_match=False) | ||
|
||
def get_busy_user_by_event_range(self, user_ids, team_id, events, cursor, table_name='event'): | ||
''' Find which users have overlapping events for the same team in this time range''' | ||
query_params = [user_ids] | ||
range_check = [] | ||
for e in events: | ||
range_check.append('(%s < `end` AND `start` < %s)') | ||
query_params += [e['start'], e['end']] | ||
|
||
# in multi-team prevent a user being scheduled if they are already scheduled for any role in any team during the same time slot | ||
query = ''' | ||
SELECT DISTINCT `user_id` FROM `%s` | ||
WHERE `user_id` in %%s AND (%s) | ||
''' % (table_name, ' OR '.join(range_check)) | ||
|
||
cursor.execute(query, query_params) | ||
return [r['user_id'] for r in cursor.fetchall()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters