diff --git a/scheduler/state_machine/controller.py b/scheduler/state_machine/controller.py index 13aff8bd..9f11a50b 100644 --- a/scheduler/state_machine/controller.py +++ b/scheduler/state_machine/controller.py @@ -257,7 +257,11 @@ def on_new_day(self, current_date: date): def check_if_end_date(self, date_to_check: date) -> bool: tracking_day = retrieve_tracking_day(self.user_id, date_to_check) # the Goal Setting state starts on day 10 of the intervention - if tracking_day >= TRACKING_DURATION: + + if tracking_day is None: + logging.warning('Tracking day not found for user: ', user_id) + + if tracking_day is not None and tracking_day >= TRACKING_DURATION: self.set_new_state(GoalsSettingState(self.user_id)) return True @@ -409,7 +413,10 @@ def run(self): def check_if_end_date(self, current_date: date): quit_date = get_quit_date(self.user_id) - if current_date >= quit_date: + if quit_date is None: + logging.warning('Quit date is not found for user ', self.user_id) + + if quit_date is not None and current_date >= quit_date: logging.info('Goals setting state ended, starting execution state') # on the quit date, notify the user that today is the quit date @@ -465,7 +472,10 @@ def on_dialog_rescheduled(self, dialog, new_date): def check_if_end_date(self, current_date: date): quit_date = get_quit_date(self.user_id) - if current_date >= quit_date: + if quit_date is None: + logging.warning('Quit date is not found for user ', self.user_id) + + if quit_date is not None and current_date >= quit_date: logging.info('Buffer state ended, starting execution state') # on the quit date, notify the user that today is the quit date