разбор метрик HAE: фикстуры, канонизация, парсер

- tmp/research/fixtures.py собирает фикстуры из архива, вычищая измерения и
  сохраняя порядок ключей, форму литералов, выравнивание меток и невидимые
  символы; шесть фикстур в internal/hae/testdata
- internal/canon — общий дом канонической формы, полноты и хеша: числа читаются
  литералом через json.Number, округление до 12 значащих цифр
- internal/hae — разбор секции metrics, вывод слоя по метрике, разделение схем
  сна, координаты интервалом; recover внутри Parse, фаззинг
- миграция bucket и docs/database.md
This commit is contained in:
av
2026-08-01 17:31:41 +03:00
parent 3e93dd95b4
commit 01d0de59df
18 changed files with 3693 additions and 21 deletions
+281
View File
@@ -0,0 +1,281 @@
{
"data": {
"metrics": [
{
"name": "active_energy",
"units": "kJ",
"data": [
{
"qty": 9.0964610089950502,
"date": "2025-06-05 00:00:00 +0300",
"source": "Device A  "
},
{
"date": "2025-06-05 01:00:00 +0300",
"qty": 1.8011831544351500,
"source": "Device A  "
},
{
"qty": 8.3677756683275249,
"source": "Device A  ",
"date": "2025-06-05 02:00:00 +0300"
},
{
"source": "Device A  ",
"qty": 3.3985452404807405,
"date": "2025-06-05 03:00:00 +0300"
},
{
"qty": 12.618722903999360,
"date": "2025-06-05 04:00:00 +0300",
"source": "Device A  "
},
{
"source": "Device A  ",
"date": "2025-06-05 05:00:00 +0300",
"qty": 40.351034546189656
},
{
"source": "Device A  ",
"qty": 6.507009541624532,
"date": "2025-06-05 06:00:00 +0300"
},
{
"date": "2025-06-06 06:00:00 +0300",
"qty": 55.821611193078514,
"source": "Device A  "
},
{
"qty": 2.295029103054565,
"date": "2025-06-06 07:00:00 +0300",
"source": "Device A  "
},
{
"date": "2025-06-06 08:00:00 +0300",
"qty": 322.8983115506521,
"source": "Device A  "
},
{
"qty": 91.588676831471213,
"date": "2025-06-06 09:00:00 +0300",
"source": "Device A  "
},
{
"qty": 462.61760657433137,
"source": "Device A  ",
"date": "2025-06-06 10:00:00 +0300"
},
{
"date": "2025-06-06 11:00:00 +0300",
"qty": 958.07555299152843,
"source": "Device A  "
},
{
"qty": 67.473524552265953,
"source": "Device A  ",
"date": "2025-06-06 12:00:00 +0300"
}
]
},
{
"units": "hr",
"data": [
{
"core": 6.2052788381114499,
"inBedEnd": "2025-06-05 05:22:26 +0300",
"date": "2025-06-05 00:00:00 +0300",
"inBed": 0,
"rem": 0.89195271872064281,
"sleepEnd": "2025-06-05 05:22:26 +0300",
"source": "Device A  ",
"totalSleep": 4.0716939170300220,
"inBedStart": "2025-06-04 22:34:34 +0300",
"asleep": 0,
"awake": 4.3396901109717361,
"sleepStart": "2025-06-04 22:34:34 +0300",
"deep": 0.68835541253715609
},
{
"awake": 9.638151247778914,
"inBed": 0,
"deep": 0.38341974910703597,
"inBedStart": "2025-06-05 22:43:20 +0300",
"rem": 0.43532011302795238,
"sleepEnd": "2025-06-06 07:57:39 +0300",
"date": "2025-06-06 00:00:00 +0300",
"core": 5.152708504451071,
"source": "Device A  ",
"asleep": 0,
"sleepStart": "2025-06-05 22:43:20 +0300",
"inBedEnd": "2025-06-06 07:57:39 +0300",
"totalSleep": 4.4003075324079272
}
],
"name": "sleep_analysis"
},
{
"name": "apple_stand_hour",
"data": [
{
"qty": 8,
"source": "Device A",
"date": "2025-06-05 07:00:00 +0300"
},
{
"source": "Device A",
"qty": 8,
"date": "2025-06-05 08:00:00 +0300"
},
{
"date": "2025-06-05 09:00:00 +0300",
"qty": 8,
"source": "Device A"
},
{
"source": "Device A",
"date": "2025-06-05 10:00:00 +0300",
"qty": 8
},
{
"source": "Device A",
"date": "2025-06-05 12:00:00 +0300",
"qty": 8
},
{
"qty": 8,
"source": "Device A",
"date": "2025-06-05 13:00:00 +0300"
},
{
"qty": 8,
"source": "Device A",
"date": "2025-06-05 15:00:00 +0300"
},
{
"qty": 8,
"date": "2025-06-05 20:00:00 +0300",
"source": "Device A"
},
{
"date": "2025-06-05 21:00:00 +0300",
"qty": 8,
"source": "Device A"
},
{
"date": "2025-06-06 02:00:00 +0300",
"source": "Device A",
"qty": 8
},
{
"qty": 8,
"source": "Device A",
"date": "2025-06-06 08:00:00 +0300"
},
{
"date": "2025-06-06 09:00:00 +0300",
"source": "Device A",
"qty": 8
},
{
"date": "2025-06-06 10:00:00 +0300",
"qty": 8,
"source": "Device A"
},
{
"source": "Device A",
"date": "2025-06-06 11:00:00 +0300",
"qty": 8
}
],
"units": "count"
},
{
"units": "ms",
"data": [
{
"date": "2025-06-05 00:00:00 +0300",
"qty": 51.209189787471513,
"source": "Device A  "
},
{
"date": "2025-06-05 02:00:00 +0300",
"source": "Device A  ",
"qty": 62.091594303847203
},
{
"date": "2025-06-05 04:00:00 +0300",
"qty": 496.11595771813635,
"source": "Device A  "
},
{
"qty": 89.502763665053950,
"source": "Device A  ",
"date": "2025-06-05 06:00:00 +0300"
},
{
"source": "Device A  ",
"qty": 15.145830153758666,
"date": "2025-06-05 08:00:00 +0300"
},
{
"source": "Device A  ",
"date": "2025-06-05 10:00:00 +0300",
"qty": 96.442927435831922
},
{
"date": "2025-06-05 12:00:00 +0300",
"qty": 16.490675484303301,
"source": "Device A  "
},
{
"date": "2025-06-05 22:00:00 +0300",
"source": "Device A  ",
"qty": 25.801867024959922
},
{
"date": "2025-06-06 00:00:00 +0300",
"qty": 23.750315211285474,
"source": "Device A  "
},
{
"source": "Device A  ",
"date": "2025-06-06 02:00:00 +0300",
"qty": 21.676280750344913
},
{
"qty": 108.159159427689,
"date": "2025-06-06 04:00:00 +0300",
"source": "Device A  "
},
{
"source": "Device A  ",
"date": "2025-06-06 06:00:00 +0300",
"qty": 14.548300046808019
},
{
"qty": 22.843350035832434,
"date": "2025-06-06 08:00:00 +0300",
"source": "Device A  "
},
{
"date": "2025-06-06 11:00:00 +0300",
"qty": 90.14058990512054,
"source": "Device A  "
}
],
"name": "heart_rate_variability"
},
{
"data": [
{
"qty": 745,
"source": "Device A",
"date": "2025-06-05 05:00:00 +0300"
}
],
"units": "m",
"name": "six_minute_walking_test_distance"
}
]
}
}