fix(import): accept a blood-glucose reading that carries no context

A CSV import of a continuous-sensor export wrote nothing and rendered a
green success state. Three faults compounded, and the reporter took all
three apart before filing.

The parser refused every BLOOD_GLUCOSE row with a blank glucoseContext.
Behind it, the CHECK constraint from migration 0021 read both ways at
once: a glucose row MUST carry a context, every other type MUST NOT. The
second half is right and stays. The first was written when the only
glucose writer was the entry form, where a person picks fasting or
post-meal at the moment of the reading. Every machine writer that
arrived since has no such answer per sample, so the Nightscout pull, the
MCP log tool, the Telegram capture and both bulk importers were all
building rows the database then refused.

A missing context now stores as NULL, never as a fifth enum member.
Every per-context reader selects by equality against the four members,
so the reading stays out of the doctor report's fasting rows, the
matching FHIR observations and the per-context targets, while the chart,
the all-time summary and the clinical panel keep it in full. Hand entry
still asks for a context, because at that moment you know it.

The import cards now read the counts rather than the status code.
Nothing written is a failure, a mixed file is a warning, and the refused
rows are grouped by reason with a count instead of fifty identical
lines, with the per-line detail one disclosure away. Both cards render
through one outcome table, so a tick cannot reach a result that wrote
nothing.

Refs #640
This commit is contained in:
Marc-André Bombeck committed 2026-07-25 21:23:26 +02:00
1 parent 019ad52c0d
commit 0c9832eb8d
19 files changed
+639 -114

No files matched your search

+28 -2
View File
@@ -4499,7 +4499,10 @@
"rateLimited": "Trop d'imports cette heure-ci (limite 5). Réessayez plus tard.",
"failed": "L'import a échoué. Veuillez réessayer.",
"readFailed": "Impossible de lire ce fichier.",
"resultSummary": "{measurements} mesures et {moods} entrées d'humeur importées, {skipped} ignorées."
"resultSummary": "{measurements} mesures et {moods} entrées d'humeur importées, {skipped} ignorées.",
"resultSuccess": "{measurements} mesures et {moods} entrées d'humeur importées.",
"resultNothing": "Rien n'a été importé. Les {skipped} entrées ont toutes été ignorées.",
"resultEmpty": "Ce fichier ne contenait ni mesures ni entrées d'humeur."
},
"csv": {
"title": "Fichier CSV",
@@ -4520,7 +4523,30 @@
"readFailed": "Impossible de lire ce fichier.",
"previewSummary": "Aperçu : {inserted} seraient importées, {skipped} ignorées.",
"resultSummary": "{inserted} nouvelles importées et {updated} mises à jour, {skipped} ignorées.",
"rowError": "Ligne {line} : {reason}"
"rowError": "Ligne {line} : {reason}",
"resultSuccess": "{inserted} nouvelles importées et {updated} mises à jour.",
"resultNothing": "Rien n'a été importé. Les {skipped} lignes ont toutes été ignorées.",
"resultEmpty": "Ce fichier a un en-tête mais aucune ligne de données.",
"previewSuccess": "Aperçu : {inserted} seraient importées.",
"previewNothing": "Aperçu : rien ne serait importé. Les {skipped} lignes seraient toutes ignorées.",
"skipGroupOne": "{count} ligne ignorée : {reason}",
"skipGroupFew": "{count} lignes ignorées : {reason}",
"skipGroupOther": "{count} lignes ignorées : {reason}",
"skipDetails": "Afficher toutes les lignes ignorées",
"reasonUnknownType": "type de mesure inconnu",
"reasonInvalidValue": "la valeur n'est pas un nombre",
"reasonValueOutOfRange": "valeur hors de la plage plausible",
"reasonUnknownUnit": "unité non reconnue pour ce type",
"reasonMissingTimezoneOffset": "horodatage sans décalage horaire",
"reasonInvalidTimestamp": "horodatage illisible",
"reasonImplausibleTimestamp": "horodatage dans le futur ou antérieur à 1900",
"reasonUnexpectedGlucoseContext": "contexte glycémique sur une ligne qui n'est pas une glycémie",
"reasonInvalidGlucoseContext": "le contexte glycémique n'est pas une valeur autorisée",
"reasonNotesTooLong": "la note est trop longue",
"reasonExternalIdTooLong": "l'identifiant externe est trop long",
"reasonUnstableExternalId": "l'identifiant externe n'est pas stable d'un export à l'autre",
"reasonDuplicate": "déjà importée",
"reasonUnknown": "ignorée"
}
},
"subtitle": "Exportez vos données ou importez depuis une sauvegarde."