Habit Streak Update (2/2)+
Minor change
This commit is contained in:
parent
8f57c2d9e3
commit
fc570208bf
@ -102,11 +102,14 @@ class Habit:
|
|||||||
# Loads the progress and checks if the streak is not broken
|
# Loads the progress and checks if the streak is not broken
|
||||||
def load_statistics(self):
|
def load_statistics(self):
|
||||||
print("loading")
|
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()]
|
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:
|
if not today in tracking_dates:
|
||||||
self.streak = 0
|
self.checked = False
|
||||||
|
if not yesterday in tracking_dates:
|
||||||
|
self.streak = 0
|
||||||
update_habit_statistics(self.id, self.count, self.count, self.streak)
|
update_habit_statistics(self.id, self.count, self.count, self.streak)
|
||||||
|
|
||||||
self.percentage = int(self.count / self.times * 100)
|
self.percentage = int(self.count / self.times * 100)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user