2024-01-23 10:32:14 +01:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
from db.SQLiteClient import create_habitTrackings, get_habitTrackings, delete_habitTrackings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
|
class HabitTrackings:
|
|
|
|
|
id: int
|
|
|
|
|
habit_id: int
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
2024-02-14 12:55:00 +01:00
|
|
|
def create(habit_id: int):
|
2024-02-12 21:07:55 +01:00
|
|
|
id = create_habitTrackings(habit_id)
|
2024-02-14 12:55:00 +01:00
|
|
|
return HabitTrackings(id, habit_id)
|
2024-01-23 10:32:14 +01:00
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def get(id: int):
|
|
|
|
|
habitTrackings = get_habitTrackings(id)
|
2024-02-14 12:55:00 +01:00
|
|
|
return HabitTrackings(habitTrackings[0], habitTrackings[1]) if habitTrackings else None
|
2024-01-23 10:32:14 +01:00
|
|
|
|
2024-01-26 09:06:47 +01:00
|
|
|
def delete(self):
|
|
|
|
|
delete_habitTrackings(self.id)
|