Salud: reset one measurement, without losing the rest
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

"Podemos reiniciar los números de esas mediciones para yo enviar el de hoy." The whole-file reset
already existed two taps away in the setup sheet, but it is the wrong size for the question: the
four metrics he suspects are not the profile. Throwing away a month of heart rate to start steps
over is not a reset, it is a tax.

So a metric can now be forgotten on its own: the detail sheet has **Reset this measurement**, which
deletes that metric's days (and hours) and nothing else — the other metrics, the workouts and the
ingest key stay. With any Date Range wider than a day the phone re-sends that metric on its next
sync, which is what makes this a reset rather than a loss: Apple Health still has the data, and a
day total replaces the day it names, so the stored past is rewritten rather than duplicated.

The two destructive rows are worded apart on purpose and the confirm names the metric ("¿Reiniciar
Pasos?"), because the neighbouring action in the setup sheet takes every metric there is.

`dropMetric()` is pure and returns how many days it took, and the route answers `metric: null` for
a metric the profile does not have (or a profile with no health file at all) instead of an error —
a screen that says "nothing stored" is more useful than a 404 answering a button press. Tested
from both ends: the helper's purity and arithmetic, the route against a real server (one metric
gone, the others and the workouts intact, the key still working, and a re-sync rebuilding it), and
the sheet's flow through the real confirm. Mutation-checked: pointing the row at the whole-file
delete fails it.
This commit is contained in:
dsantillan committed 2026-09-23 16:18:28 -04:00
1 parent d93861a73f
commit 5c69540f62
11 files changed
+209 -7

No files matched your search

+6
View File
@@ -48,6 +48,12 @@ the setting that decides whether history exists at all: with HAE's default `Toda
never sent, which is exactly what a card frozen on a single day looks like — `Previous 7 Days` is
what the setup steps now say.
A metric can also be **reset on its own** (its detail sheet → *Reset this measurement*): the days
and hours stored for that one measurement go, every other metric stays, and the next sync rebuilds
it from the phone. That is the shape of the question people actually arrive with — "these steps
look wrong, start them over" — and it is not the same as the profile-wide *Delete the health data*
two taps away in the setup sheet, which is why the two are worded apart.
Also here: the watch's workouts are shown **read-only** in Salud and deliberately kept out of the
history — they carry no sets or weights, so folding them into progression, PRs and the recovery
model would be inventing data. Coverage: `api/vitals.js` (19 tests), the routes against a real