From 1180893dd1002fb29120d1ca2b7bf12e04a82e88 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Wed, 14 Feb 2024 10:41:03 +0100 Subject: [PATCH 1/3] Fixed Yassins code removal --- models/Habit.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/models/Habit.py b/models/Habit.py index 34edf10..9c26954 100644 --- a/models/Habit.py +++ b/models/Habit.py @@ -80,6 +80,9 @@ class Habit: count = 0 self.checked = False for tracking in self.get_habitTrackings(): + if tracking.created_at.date() == datetime.today().date(): + self.checked = True + # day if self.unit == 0: if tracking.created_at.date() == datetime.today().date(): From 0f060e81a409409ba85081268daa8ffa0268a6b7 Mon Sep 17 00:00:00 2001 From: Verox001 Date: Wed, 14 Feb 2024 10:50:23 +0100 Subject: [PATCH 2/3] Fixed animation and color change of habit progress bar --- templates/index.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index 793795f..81c5a0e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -177,11 +177,14 @@ var habitBlock = document.getElementById("habit-" + habitId); if (percentage == 100) { - progressBar.style.backgroundColor = "green"; habitBlock.classList.add("animate-bounce"); setTimeout(function () { habitBlock.classList.remove("animate-bounce"); }, 2000); + } + + if (percentage >= 100) { + progressBar.style.backgroundColor = "green"; } else { progressBar.style.backgroundColor = ""; habitBlock.classList.remove("animate-bounce"); @@ -209,7 +212,9 @@ var percentage = response.data.percentage; var progressBar = document.getElementById("progress-bar-" + habitId); progressBar.style.width = percentage + "%"; - checkCompletionAndAnimate(habitId, percentage); + if (response.data.unchecked) { + checkCompletionAndAnimate(habitId, percentage); + } }).catch(function (error) { // Handle the error if needed console.error('Error:', error); From aaeb04d4abd8d0f0060490e772b9fa24e0a29c82 Mon Sep 17 00:00:00 2001 From: Yapollon Date: Wed, 14 Feb 2024 10:52:25 +0100 Subject: [PATCH 3/3] Heatmap done? yes --- models/User.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/models/User.py b/models/User.py index e4f2384..13f9f72 100644 --- a/models/User.py +++ b/models/User.py @@ -1,8 +1,8 @@ from datetime import datetime from flask_login import UserMixin -from db.SQLiteClient import create_user, get_user, get_user_by_email, get_habits, delete_user, update_user, \ - get_habitLists +from db.SQLiteClient import create_user, get_user, get_user_by_email, delete_user, update_user, \ + get_habitLists, get_heatmap_value class User(UserMixin): @@ -43,3 +43,10 @@ class User(UserMixin): habitLists.append(habitList) return habitLists + + def get_heatmap(self): + heatmap = [] + for day in range (0, 27): + value = get_heatmap_value(self.id, day) + heatmap.append(value) + return heatmap \ No newline at end of file