2021-12-02 22:08:58 +00:00
|
|
|
from typing import Optional, Any
|
|
|
|
from dataclasses import dataclass, field
|
|
|
|
|
|
|
|
# A nomie habit tracker. Tracks anything whose value can be encapsulated in a numerical value.
|
2021-12-03 15:22:54 +00:00
|
|
|
@dataclass(frozen=True)
|
2021-12-02 22:08:58 +00:00
|
|
|
class Tracker:
|
|
|
|
color: str
|
|
|
|
emoji: str
|
|
|
|
hidden: bool
|
|
|
|
id: str
|
|
|
|
ignore_zeros: bool
|
|
|
|
label: str
|
|
|
|
math: str
|
|
|
|
one_tap: bool
|
|
|
|
tag: str
|
|
|
|
type: str
|
|
|
|
uom: str
|
|
|
|
# TODO no idea what include does
|
|
|
|
include: str
|
|
|
|
min: Optional[int] = 0
|
|
|
|
max: Optional[int] = 0
|
|
|
|
goal: Optional[int] = 0
|
|
|
|
default: Optional[int] = 0
|
|
|
|
# TODO score can be string (if custom) or int (if simple good/bad)
|
|
|
|
score: Optional[str] = ""
|
|
|
|
score_calc: Optional[list[dict[str, Any]]] = field(default_factory=lambda: [])
|
|
|
|
|
|
|
|
|
2021-12-03 15:22:54 +00:00
|
|
|
@dataclass(frozen=True)
|
|
|
|
class Activity:
|
|
|
|
tracker: Tracker
|
|
|
|
value: Optional[int] = 1
|
|
|
|
|
|
|
|
|
2021-12-02 22:08:58 +00:00
|
|
|
# A nomie note. Records any circumstance of 'something happened' through prose.
|
|
|
|
# These are undigested events, whose changed trackers are still encapsulated
|
|
|
|
# in the 'note' field as continuous text.
|
2021-12-03 15:22:54 +00:00
|
|
|
@dataclass(frozen=True)
|
2021-12-02 22:08:58 +00:00
|
|
|
class Event:
|
|
|
|
id: str
|
|
|
|
start: int
|
|
|
|
end: int
|
2021-12-03 15:22:54 +00:00
|
|
|
text: str
|
|
|
|
activities: Optional[list[Activity]] = field(default_factory=lambda: [])
|
|
|
|
score: Optional[int] = 0
|
|
|
|
lat: Optional[float] = 0.0
|
|
|
|
lng: Optional[float] = 0.0
|
2021-12-02 22:08:58 +00:00
|
|
|
location: Optional[str] = ""
|
2021-12-03 15:22:54 +00:00
|
|
|
modified: Optional[bool] = False
|
|
|
|
offset: Optional[str] = "" # local timezone offset?
|
|
|
|
source: Optional[str] = "n5" # nomie version
|
2021-12-02 22:08:58 +00:00
|
|
|
|
|
|
|
|
2021-12-03 15:22:54 +00:00
|
|
|
@dataclass(frozen=True)
|
2021-12-02 22:08:58 +00:00
|
|
|
class NomieImport:
|
|
|
|
version: str
|
|
|
|
trackers: list[Tracker]
|
|
|
|
events: list[Event]
|