Habit Streak Update (2/2)+

Minor change
This commit is contained in:
Yapollon 2024-02-28 14:28:31 +01:00
parent 8f57c2d9e3
commit fc570208bf

View File

@ -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)