diff --git a/models/Habit.py b/models/Habit.py index d0fee6d..83ad11b 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -102,11 +102,14 @@ class Habit: # Loads the progress and checks if the streak is not broken def load_statistics(self): print("loading") - today_date = datetime.today().date() + today = datetime.today().date() + yesterday = today - timedelta(days=1) tracking_dates = [tracking.created_at.date() for tracking in self.get_habitTrackings()] - yesterday = today_date - timedelta(days=1) - if not self.checked and not yesterday in tracking_dates: - self.streak = 0 + + if not today in tracking_dates: + self.checked = False + if not yesterday in tracking_dates: + self.streak = 0 update_habit_statistics(self.id, self.count, self.count, self.streak) self.percentage = int(self.count / self.times * 100)