Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
454ce33846
@ -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,13 @@ class Habit:
|
||||
datetime.strptime(rawTracking[2], "%Y-%m-%dT%H:%M:%S.%f")))
|
||||
return trackings
|
||||
|
||||
|
||||
def fill_statistics(self):
|
||||
count = 0
|
||||
self.checked = False
|
||||
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 +99,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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user