Progessbar Update
If the Time selected by the unit is over the count will drop to 0
This commit is contained in:
parent
fe91faf5b1
commit
f81ec8368c
2
app.py
2
app.py
@ -67,6 +67,8 @@ def index():
|
|||||||
# Sort habits by whether they have been checked today and then by slot
|
# Sort habits by whether they have been checked today and then by slot
|
||||||
for habit_list in habit_lists:
|
for habit_list in habit_lists:
|
||||||
habit_list.habits = sorted(habit_list.get_habits(), key=lambda habit: (habit.checked, habit.slot))
|
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(
|
return render_template(
|
||||||
'index.html',
|
'index.html',
|
||||||
|
|||||||
@ -111,6 +111,16 @@ class Habit:
|
|||||||
self.streak = 0
|
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)
|
||||||
|
|
||||||
|
# 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)
|
self.percentage = int(self.count / self.times * 100)
|
||||||
|
|
||||||
# Saves the progress count and streak
|
# Saves the progress count and streak
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user