From e43680ea071902bcb193107d1e3c0e635d13e28d Mon Sep 17 00:00:00 2001 From: MitchellJC <81349046+MitchellJC@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:32:50 +1000 Subject: [PATCH] ref, feat: added id for posture and documented prop_good --- client/data/resources/database.dbml | 6 +++++- client/data/routines.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/data/resources/database.dbml b/client/data/resources/database.dbml index 9541db4..befc143 100644 --- a/client/data/resources/database.dbml +++ b/client/data/resources/database.dbml @@ -7,8 +7,12 @@ Table user { } Table posture { + id INTEGER [primary key, unique, increment] user_id INTEGER [ref: > user.id] - prop_good REAL + + // Proportion of time that posture is good within period + prop_good REAL + period_start DATETIME period_end DATETIME } \ No newline at end of file diff --git a/client/data/routines.py b/client/data/routines.py index 0297aa3..ff929fe 100644 --- a/client/data/routines.py +++ b/client/data/routines.py @@ -1,11 +1,11 @@ -"""Routines that can be integrated into main control flow.""" +"""Data routines that can be integrated into main control flow.""" import sqlite3 from typing import Any from importlib import resources from pydbml import PyDBML -DATABASE_DEFINTION = resources.files("data.resources").joinpath("database.dbml") +DATABASE_DEFINITION = resources.files("data.resources").joinpath("database.dbml") DATABASE_RESOURCE = resources.files("data.resources").joinpath("database.db") @@ -16,7 +16,7 @@ def init_database() -> None: if database_file.is_file(): return - parsed = PyDBML(DATABASE_DEFINTION) + parsed = PyDBML(DATABASE_DEFINITION) init_script = parsed.sql connection = sqlite3.connect(database_file)