Commit 0f16159

derdilla <82763757+NobodyForNothing@users.noreply.github.com>
2024-03-29 23:15:43
add remaining documentation
Signed-off-by: derdilla <82763757+NobodyForNothing@users.noreply.github.com>
1 parent d02fc45
Changed files (4)
docs/resources/db-scheme.png
Binary file
docs/files.md
@@ -0,0 +1,21 @@
+# App files
+
+The app stores persistent data in the app storage. This document aims to provide an overview of the purpose and structure of the files stored.
+
+## Current files
+
+The `dbPath`/`config.db` file is a SQLite3 database containing Settings and some other configuration data such as the current display ranges and added medications. The database contains tables for logically different parts of the config, which all contain one line with the config in json format and an userid (which currently serves no purpose). The intervall table contains multiple entries.
+
+In the `dbPath`/`blood_pressure.db` SQLite3 database you find one `bloodPressureModel` table containing entries with the blood pressure records including a json representation of the color in the ("needlePin") column.
+
+The `await getDatabasesPath()`/`medicine.intakes` File consists of a plain text csv like representation of medicine intakes. The format of this file was rather experimental and gets replaced as part of [#257](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/issues/257). For an exact description look at the `deserialize` factory method of the `IntakeHistory` class, but in general every line (including the first) contains a medicine intake with fields seperated by `\x00`. The first field is the medicine id, the second is the time the medicine was taken in milliseconds since epoch and the third is the dosis of the medicine.
+
+## Exported files
+
+Exporting the records as a SqliteDB will export a copy of the `blood_pressure.db` file described above. Similarly, the settings export will yield the `config.db` file as present in storage.
+
+When exporting the data as CSV, the file will use standard platform newlines (`\r\n`) unless not configured differently a headline with the names of all exported columns delimited by the `,` character. Unlike the config suggests note strings are not always wrapped in `'` characters. Fields without any value are either empty or contain a lowercase `null`.
+
+## Legacy data
+
+Until [#189](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/pull/189) and [#195](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/pull/195) ([v1.5.5](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/tree/v1.5.5)) settings were stored in androids shared preferences storage. It consisted of a lot of individual keys and update code can be found in the [update_legacy_settings.dart](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/blob/main/app/lib/model/storage/update_legacy_settings.dart) file. Support will be dropped in october 2024 (a year after migration started).
\ No newline at end of file
health_data_store/lib/src/database_manager.dart
@@ -8,8 +8,7 @@ import 'package:sqflite_common/sqlite_api.dart';
 ///
 /// ## DB scheme
 ///
-/// ![Diagram](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/assets/82763757/62edb58c-c579-4ce1-990c-be7889657fa7)
-/// // TODO: replace with updating file once merged
+/// ![Diagram](https://github.com/NobodyForNothing/blood-pressure-monitor-fl/blob/main/docs/resources/db-scheme.png?raw=true)
 ///
 /// ## Types
 /// Data in the database tries to always use the most common SI-units.
@@ -83,7 +82,9 @@ class DatabaseManager {
     await txn.execute('CREATE TABLE "Notes" ('
       '"entryID"	INTEGER NOT NULL,'
       '"note"     TEXT,'
-      '"color"    INTEGER,' // TODO: add attachments
+      // When implementing attachments instead of updating this scheme note text
+      // can be interpreted as markdown and support formatting as well as files.
+      '"color"    INTEGER,'
       'FOREIGN KEY("entryID") REFERENCES "Timestamps"("entryID"),'
       'PRIMARY KEY("entryID")'
     ');');
health_data_store/lib/health_data_store.dart
@@ -1,5 +1,28 @@
 /// Package to easily store health domain data.
-library; // TODO: doc more
+///
+/// This package provides a safe abstraction over the underlying databases and
+/// is constructed in a way that allows to add new measurement types without
+/// problems. It follows higher standards regarding backwards compatability and
+/// code quality than the rest of the project to prevent data loss.
+///
+/// All data managed by this package is present in [SI-Units](https://en.wikipedia.org/wiki/SI_units)
+/// and dates are rounded to the second.
+///
+/// To get started call `HealthDataStore.load` with a *new* database object. All
+/// database interaction including table setup and versioning will be performed
+/// by this library, to avoid inconsistencies and confusion about
+/// responsibility.
+///
+/// Every type of entry (`BloodPressureRecord`, `MedicineIntake` and `Note`) is
+/// organized in its own repository. The `MedicineRepository` allows to store
+/// medicines used in intakes. Adding medicines to this repository before
+/// storing them in the intake repository is required for the intake repository
+/// to function correctly.
+///
+/// Repositories allow querying all entries in a `DateRange` which is a custom
+/// implementation of flutters `DateTimeRange` due to the fact that this is a
+/// dart library and to facilitate the use of second based timestamps.
+library;
 
 export 'src/health_data_store.dart';
 // repositories