From 0a475b9f9970ca7880533b81b1843e28b6dea9a6 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Tue, 13 Feb 2024 11:14:34 +0100 Subject: [PATCH 1/4] Fixed date comparision --- models/Habit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/models/Habit.py b/models/Habit.py index f524854..0f86cf3 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -85,7 +85,8 @@ class Habit: count = 0 self.checked = False for tracking in self.get_habitTrackings(): - if tracking.created_at == datetime.today(): + print(tracking.created_at, datetime.today()) + if tracking.created_at.date() == datetime.today().date(): self.checked = True # day From ae1ffd21fe601cabc9636e7126cf7aa1511b0f49 Mon Sep 17 00:00:00 2001 From: Yapollon Date: Tue, 13 Feb 2024 11:17:06 +0100 Subject: [PATCH 2/4] hotfix habit --- models/Habit.py | 9 +-------- models/User.py | 8 -------- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/models/Habit.py b/models/Habit.py index 173afa3..9e0144a 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -40,7 +40,6 @@ class Habit: return habit - def update(self, name: str=None, note: str=None, times: int=None, unit: int=None): update_habit(self.id, name, note, times, unit) if name is not None: @@ -52,7 +51,6 @@ class Habit: if unit is not None: self.unit = unit - def update_slot(self, new_slot: int): slots = get_slots(self.list_id) if new_slot > self.slot: @@ -65,14 +63,12 @@ class Habit: update_slot(slot[0], slot[1]+1) update_slot(self.id, new_slot) - def delete(self): slots = get_slots(self.list_id)[self.slot+1:] for slot in slots: update_slot(slot[0], slot[1] - 1) delete_habit(self.id) - def get_habitTrackings(self) -> list[HabitTrackings]: trackings = [] for rawTracking in get_habitTrackings_by_habit_id(self.id): @@ -80,13 +76,12 @@ class Habit: datetime.strptime(rawTracking[2], "%Y-%m-%dT%H:%M:%S.%f"))) return trackings - def fill_statistics(self): count = 0 for tracking in self.get_habitTrackings(): # day if self.unit == 0: - if tracking.created_at == datetime.today(): + if tracking.created_at.date() == datetime.today().date(): count += 1 # week elif self.unit == 1: @@ -103,11 +98,9 @@ class Habit: self.percentage = int(count / self.times * 100) - def to_json(self): return json.dumps(self, default=lambda o: o.__dict__, sort_keys=True, indent=4) - def habit_list(self): from models.HabitList import HabitList raw_habitLists = get_habitList(self.list_id) diff --git a/models/User.py b/models/User.py index 9657f96..e4f2384 100644 --- a/models/User.py +++ b/models/User.py @@ -33,14 +33,6 @@ class User(UserMixin): def delete(self): delete_user(self.id) - # def get_habits(self): - # raw_habits = get_habits(self.id) - # habits = [] - # for habit in raw_habits: - # habit = Habit(habit[0], habit[1], habit[2], habit[3], habit[4], habit[5], habit[6]) - # habits.append(habit) - # return habits - def get_habitLists(self): from models.HabitList import HabitList From da2246890060e17fd58289dd27541ab90c63080d Mon Sep 17 00:00:00 2001 From: Verox001 Date: Wed, 14 Feb 2024 10:33:12 +0100 Subject: [PATCH 3/4] Revert "Fixed date comparision" This reverts commit 0a475b9f9970ca7880533b81b1843e28b6dea9a6. --- models/Habit.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/models/Habit.py b/models/Habit.py index 0f86cf3..f524854 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -85,8 +85,7 @@ class Habit: count = 0 self.checked = False for tracking in self.get_habitTrackings(): - print(tracking.created_at, datetime.today()) - if tracking.created_at.date() == datetime.today().date(): + if tracking.created_at == datetime.today(): self.checked = True # day From b446bb55aac6b7f49966d3353f7ac6c7ca1976de Mon Sep 17 00:00:00 2001 From: Verox001 Date: Wed, 14 Feb 2024 10:36:02 +0100 Subject: [PATCH 4/4] Added checked attribute again --- models/Habit.py | 1 + 1 file changed, 1 insertion(+) diff --git a/models/Habit.py b/models/Habit.py index 9e0144a..34edf10 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -78,6 +78,7 @@ class Habit: def fill_statistics(self): count = 0 + self.checked = False for tracking in self.get_habitTrackings(): # day if self.unit == 0: