24 lines
654 B
Python
24 lines
654 B
Python
|
|
from dataclasses import dataclass
|
||
|
|
from db.SQLiteClient import create_habitTrackings, get_habitTrackings, delete_habitTrackings
|
||
|
|
|
||
|
|
|
||
|
|
@dataclass
|
||
|
|
class HabitTrackings:
|
||
|
|
id: int
|
||
|
|
habit_id: int
|
||
|
|
times: int
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def create(habit_id: int, times: int):
|
||
|
|
id = create_habitTrackings(habit_id, times)
|
||
|
|
return HabitTrackings(id, habit_id, times)
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def get(id: int):
|
||
|
|
habitTrackings = get_habitTrackings(id)
|
||
|
|
return HabitTrackings(habitTrackings[0], habitTrackings[1], habitTrackings[2]) if habitTrackings else None
|
||
|
|
|
||
|
|
@staticmethod
|
||
|
|
def delete(id: int):
|
||
|
|
delete_habitTrackings(id)
|