Skip to content

Commit 8307a00

Browse files
authored
Merge pull request #203 from PerfectFit-project/483-new-quit-date
Added a none check for quit date so it doesn't cause an error
2 parents b1b69fd + f67fad5 commit 8307a00

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

scheduler/state_machine/controller.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,10 @@ def on_new_day(self, current_date: date):
257257
def check_if_end_date(self, date_to_check: date) -> bool:
258258
tracking_day = retrieve_tracking_day(self.user_id, date_to_check)
259259
# the Goal Setting state starts on day 10 of the intervention
260-
if tracking_day >= TRACKING_DURATION:
260+
261+
if tracking_day is None:
262+
logging.warning(f'Tracking day is not found for user {self.user_id}')
263+
elif tracking_day >= TRACKING_DURATION:
261264
self.set_new_state(GoalsSettingState(self.user_id))
262265
return True
263266

@@ -409,7 +412,9 @@ def run(self):
409412
def check_if_end_date(self, current_date: date):
410413
quit_date = get_quit_date(self.user_id)
411414

412-
if current_date >= quit_date:
415+
if quit_date is None:
416+
logging.warning(f'Quit date is not found for user {self.user_id}')
417+
elif current_date >= quit_date:
413418
logging.info('Goals setting state ended, starting execution state')
414419

415420
# on the quit date, notify the user that today is the quit date
@@ -465,7 +470,9 @@ def on_dialog_rescheduled(self, dialog, new_date):
465470
def check_if_end_date(self, current_date: date):
466471
quit_date = get_quit_date(self.user_id)
467472

468-
if current_date >= quit_date:
473+
if quit_date is None:
474+
logging.warning(f'Quit date is not found for user {self.user_id}')
475+
elif current_date >= quit_date:
469476
logging.info('Buffer state ended, starting execution state')
470477

471478
# on the quit date, notify the user that today is the quit date

0 commit comments

Comments
 (0)