mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
fix(ecg): accept the fractional heart rate and frequency HealthKit reports
The ingest route required integers for the average heart rate and the sampling frequency. HealthKit reports both as doubles and a watch's average heart rate is often fractional, so most new recordings were refused with 422 while older ones, whose value happened to be whole, went through. Both are now accepted as numbers and rounded once before they are stored; the columns stay integers. A refused body now logs which fields were refused and why, never their values. Refs #1060
This commit is contained in:
1 parent
28054e69c2
commit
0dfce73570
3 files changed
+48
-7
No files matched your search
@@ -188,6 +188,23 @@ describe("POST /api/insights/ecg — round trip through the real routes", () =>
|
||||
expect(detail.body.classification).toBe("NOT_DETECTED");
|
||||
});
|
||||
|
||||
it("accepts the fractional heart rate and frequency HealthKit reports and rounds them (#1060)", async () => {
|
||||
// HealthKit hands both over as doubles; a watch's average heart rate is
|
||||
// often fractional. Requiring integers refused those recordings outright.
|
||||
const posted = await ingest(
|
||||
ingestPayload({ averageHeartRate: 64.7, samplingFrequency: 511.96 }),
|
||||
);
|
||||
expect(posted.status).toBe(201);
|
||||
expect(posted.data.status).toBe("inserted");
|
||||
|
||||
const list = await readList();
|
||||
expect(list.recordings[0]).toMatchObject({
|
||||
averageHeartRate: 65,
|
||||
samplingFrequency: 512,
|
||||
});
|
||||
expect(posted.data.durationSeconds).toBeCloseTo(SAMPLES.length / 512, 10);
|
||||
});
|
||||
|
||||
it("never writes the waveform as plaintext", async () => {
|
||||
const posted = await ingest(ingestPayload());
|
||||
const row = await getPrismaClient().ecgRecording.findUniqueOrThrow({
|
||||
|
||||
Reference in new issue
Block a user