2021-12-02 22:08:58 +00:00
|
|
|
from typing import Optional
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from uuid import uuid4
|
|
|
|
|
2021-12-03 15:22:54 +00:00
|
|
|
# A loop Habit representation.
|
|
|
|
# Tracks anything whose value can be encapsulated in a numerical value.
|
2021-12-02 22:08:58 +00:00
|
|
|
@dataclass
|
|
|
|
class Habit:
|
|
|
|
name: str
|
2021-12-06 15:37:59 +00:00
|
|
|
type: int = 0 # 1 is range counter
|
|
|
|
archived: int = 0
|
|
|
|
color: int = 0
|
|
|
|
highlight: int = 0
|
|
|
|
freq_den: int = 1
|
|
|
|
freq_num: int = 1
|
|
|
|
target_value: int = 0
|
|
|
|
description: str = ""
|
|
|
|
question: str = ""
|
|
|
|
unit: str = ""
|
|
|
|
position: int = 0
|
|
|
|
uuid: str = ""
|
2021-12-02 22:08:58 +00:00
|
|
|
|
|
|
|
def __post_init__(self):
|
2021-12-06 15:37:59 +00:00
|
|
|
if not self.uuid or self.uuid == "":
|
2021-12-02 22:08:58 +00:00
|
|
|
self.uuid = uuid4().hex
|
2021-12-03 15:22:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
# A Loop repetition representation, containing only the bare minimum
|
|
|
|
# for its successful entry into the Loop Habit Tracker database.
|
|
|
|
@dataclass
|
|
|
|
class Repetition:
|
|
|
|
habit_uuid: str
|
|
|
|
timestamp: int
|
|
|
|
value: Optional[int]
|