Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a none check for quit date so it doesn't cause an error #203

Merged
merged 4 commits into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions scheduler/state_machine/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ 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(f'Tracking day is not found for user {self.user_id}')
elif tracking_day >= TRACKING_DURATION:
self.set_new_state(GoalsSettingState(self.user_id))
return True

Expand Down Expand Up @@ -409,7 +412,9 @@ 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(f'Quit date is not found for user {self.user_id}')
elif 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
Expand Down Expand Up @@ -465,7 +470,9 @@ 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(f'Quit date is not found for user {self.user_id}')
elif 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
Expand Down
Loading