habitmove/habitmove/nomiedata.py
Marty Oehme 3da96a3ef8
Add all simultaneous activities to loop
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.
2021-12-06 20:40:37 +01:00

59 lines
1.4 KiB
Python

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.
@dataclass(frozen=True)
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: int = 0
max: int = 0
goal: int = 0
default: int = 0
# TODO score can be string (if custom) or int (if simple good/bad)
score: str = ""
score_calc: list[dict[str, Any]] = field(default_factory=lambda: [])
@dataclass(frozen=True)
class Activity:
tracker: Tracker
value: int = 1
# 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.
@dataclass(frozen=True)
class Event:
id: str
start: int
end: int
text: str
activities: list[Activity] = field(default_factory=lambda: [])
score: int = 0
lat: float = 0.0
lng: float = 0.0
location: str = ""
modified: bool = False
offset: str = "" # local timezone offset?
source: str = "n5" # nomie version
@dataclass(frozen=True)
class NomieImport:
version: str
trackers: list[Tracker]
events: list[Event]