While in nomie, multiple occurences of the same activity can be recorded in one single event (e.g. you smoked multiple cigarettes and now record that fact), Loop has no such concept. Thus, we work around it by fudging the duplicate timestamps ever so slightly (one millisecond each) and then adding them to the database.
35 lines
889 B
Python
35 lines
889 B
Python
from typing import Optional
|
|
from dataclasses import dataclass
|
|
from uuid import uuid4
|
|
|
|
# A loop Habit representation.
|
|
# Tracks anything whose value can be encapsulated in a numerical value.
|
|
@dataclass
|
|
class Habit:
|
|
name: str
|
|
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 = ""
|
|
|
|
# TODO test post init uuid setting
|
|
def __post_init__(self):
|
|
if not self.uuid or self.uuid == "":
|
|
self.uuid = uuid4().hex
|
|
|
|
|
|
# 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]
|