fix(ecg): let a whole sweep of recordings through the ingest limit

The iPhone app posts every ECG its sweep has not yet consumed and, on a
429, stops and restarts the same sweep on its next wake. With a limit of
60 per minute a sweep of 61 or more could never finish: the same last
recording was refused on every sync, so the newest ECG never arrived. The
limit is 600 per minute now, enough for more than a decade of weekly
strips in one sweep.

Refs #1060
This commit is contained in:
Marc-André Bombeck committed 2026-10-01 21:53:37 +02:00
1 parent fc47006c88
commit 82ccac2fd0
2 files changed
+27 -4

No files matched your search

@@ -205,6 +205,24 @@ describe("POST /api/insights/ecg — round trip through the real routes", () =>
expect(posted.data.durationSeconds).toBeCloseTo(SAMPLES.length / 512, 10);
});
it("takes a whole sweep of recordings in one go (#1060)", async () => {
// The app posts every recording its sweep has not consumed and restarts
// the sweep after a 429; a limit below the sweep's size refused the same
// last recording on every sync. Seventy distinct strips must all land.
const statuses: number[] = [];
for (let i = 0; i < 70; i += 1) {
const posted = await ingest(
ingestPayload({
externalRecordingId: `sweep-${i}`,
recordedAt: new Date(Date.UTC(2026, 5, 1, 8, i)).toISOString(),
}),
);
statuses.push(posted.status);
}
expect(statuses.filter((s) => s === 429)).toHaveLength(0);
expect(await getPrismaClient().ecgRecording.count()).toBe(70);
});
it("never writes the waveform as plaintext", async () => {
const posted = await ingest(ingestPayload());
const row = await getPrismaClient().ecgRecording.findUniqueOrThrow({