From 3315022045e79109c94cb59966a735543b3b0697 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 18 Aug 2016 11:37:49 -0600 Subject: Fix a bug where the ignore list would be cleared when updating the standup schedule --- warmachine/addons/standup.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/warmachine/addons/standup.py b/warmachine/addons/standup.py index 0d46408..59c4f3c 100644 --- a/warmachine/addons/standup.py +++ b/warmachine/addons/standup.py @@ -191,7 +191,19 @@ class StandUpPlugin(WarMachinePlugin): def schedule_standup(self, connection, channel, time24h): """ - Schedules a standup by creating a Task to be run in the future. + Schedules a standup by creating a Task to be run in the future. This + populates ``self.standup_schedules[channel]`` with the following keys: + - ``f`` (:class:`asyncio.Task`): This is the asyncio task object. + - ``datetime`` (:class:`datetime.datetime`): The datetime of when the + standup will run next. + - ``time24h`` (str): 24 hour time the schedule should be executed at. + - ``ignoring`` (list): List of usernames to ignore when asking for + their standup update. + + Args: + connection (:class:`Connection`): the connection + channel (str): channel name to schedule standup for + time24h (str): The 24 hour time to start the standup at """ next_standup = self.get_next_standup_secs(time24h) @@ -202,12 +214,20 @@ class StandUpPlugin(WarMachinePlugin): next_standup_secs, functools.partial( self.standup_schedule_func, connection, channel)) - self.standup_schedules[channel] = { - 'future': f, - 'datetime': next_standup, - 'time24h': time24h, - 'ignoring': [], - } + # Don't overwrite existing setting if they exist + if channel in self.standup_schedules: + self.standup_schedules[channel]['f'].cancel() + + self.standup_schedules[channel]['f'] = f + self.standup_schedules[channel]['datetime'] = next_standup + self.standup_schedules[channel]['time24h'] = time24h + else: + self.standup_schedules[channel] = { + 'future': f, + 'datetime': next_standup, + 'time24h': time24h, + 'ignoring': [], + } self.log.info('New schedule added to channel {} for {}'.format( channel, time24h)) -- cgit v1.2.1