diff --git a/app.py b/app.py index f6f1df4..ae28e74 100644 --- a/app.py +++ b/app.py @@ -67,6 +67,8 @@ def index(): # Sort habits by whether they have been checked today and then by slot for habit_list in habit_lists: habit_list.habits = sorted(habit_list.get_habits(), key=lambda habit: (habit.checked, habit.slot)) + for habit in habit_list.get_habits(): + habit.load_statistics() return render_template( 'index.html', diff --git a/models/Habit.py b/models/Habit.py index 5b454b5..d9835d5 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -111,6 +111,16 @@ class Habit: self.streak = 0 update_habit_statistics(self.id, self.count, self.count, self.streak) + # Reset count based on time unit + if self.unit == 0: + self.count = 0 + elif self.unit == 1 and today.weekday() == 0: + self.count = 0 + elif self.unit == 2 and today.day == 1: + self.count = 0 + elif self.unit == 3 and today.month == 1 and today.day == 1: + self.count = 0 + self.percentage = int(self.count / self.times * 100) # Saves the progress count and streak