habitmove/habitmove/loopdata.py

36 lines
992 B
Python
Raw Normal View History

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
type: Optional[int] = 0 # 1 is range counter
archived: Optional[int] = 0
color: Optional[int] = 0
highlight: Optional[int] = 0
freq_den: Optional[int] = 1
freq_num: Optional[int] = 1
target_value: Optional[int] = 0
description: Optional[str] = ""
question: Optional[str] = ""
unit: Optional[str] = ""
position: Optional[int] = 0
uuid: Optional[str] = None
# TODO test post init uuid setting
def __post_init__(self):
if not self.uuid:
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]