Nährwerte-Autofill beim Scan + Fix: syncId-Import-Kollision#96
Merged
Conversation
Open Food Facts liefert energy-kcal_100g + Packungsgröße (product_quantity) -> lookupBarcode berechnet daraus "kcal pro Einheit" und füllt das neue kcal-Feld beim Scannen automatisch vor (nur wenn das Feld noch leer ist). So füllt sich der kalorienbasierte Autarkie-Score quasi von selbst. - utils.lookupBarcode: nutriments + product_quantity abgefragt, kcalPerUnit = round(kcal100 * packGröße / 100) (nur bei plausiblen Werten). - ScannedData + InlineScanner/handleScanned + BarcodeScanner reichen kcalPerUnit bis ins Formular durch. https://claude.ai/code/session_011LpmXuRXfBvy84x3Kk8ng8
Re-Import eines Backups (oder Import auf demselben Gerät) konnte den &syncId-Unique-Index verletzen: "Unable to add key to index 'syncId'…". Ursache: Import übernahm die syncId aus dem Backup unverändert, auch wenn sie lokal bereits existierte (und die Name+MHD+Lagerort-Duplikaterkennung nicht griff). Fix: Beim Import wird die eingehende syncId nur übernommen, wenn sie frei ist — sonst wird eine neue erzeugt. Gilt für Produkte, Lagerorte und Verbrauchslogs. + Regressionstest. https://claude.ai/code/session_011LpmXuRXfBvy84x3Kk8ng8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Nährwerte automatisch beim Scan + Fix für Import-Crash
Zwei Dinge in dieser PR.
1. Nährwerte automatisch beim Barcode-Scan übernehmen
Ergänzt den kalorienbasierten Autarkie-Score: Open Food Facts liefert
energy-kcal_100g+ Packungsgröße (product_quantity) →lookupBarcodeberechnet „kcal pro Einheit" und füllt das Feld beim Scannen automatisch vor (nur wenn noch leer). Der Autarkie-Score füllt sich so quasi von selbst.kcalPerUnit = round(kcal/100g × Packungsgröße / 100)(nur bei plausiblen Werten).ScannedData→ Inline-/Haupt-Scanner → Formular.2. Fix:
ConstraintErrorauf uniquesyncIdbeim Import (gemeldeter Crash)Ursache: Der Import übernahm die
syncIdaus dem Backup unverändert — existierte sie lokal schon (Re-Import / Backup vom selben Gerät) und griff die Name+MHD+Lagerort-Duplikaterkennung nicht, kollidierte der&syncId-Unique-Index → Crash.Fix: Beim Import wird die eingehende
syncIdnur übernommen, wenn sie frei ist — sonst neu erzeugt. Für Produkte, Lagerorte und Verbrauchslogs. + Regressionstest.Verifikation
✅
tscsauber · 110 Unit (1 neuer Kollisions-Test) + 5 E2E grün · Build ok.https://claude.ai/code/session_011LpmXuRXfBvy84x3Kk8ng8
Generated by Claude Code