feat: Add FDC nutrition information per ingredient#6747
feat: Add FDC nutrition information per ingredient#6747EinToni wants to merge 3 commits intomealie-recipes:mealie-nextfrom
Conversation
|
I think this is definitely a step in the right direction for better nutritional data support. I wonder if we should hold off on this until we have better unit handling with a base unit/conversions, etc. This is something in the backlog to support other areas of the app too. Do you think it would make sense to wait for that first? I worry adding this before we have a better handle on units/conversions may cause a lot of headache. I haven't looked too closely at your implementation yet but I read your PR description mentioning this. |
|
In addition to what @michael-genson suggested, would it be possible to make this feature more food composition database agnostic? As a user in Norway, I would be more interested in getting these values from the database that the Norwegian Food Safety Authority publishes. An alternative would also be the European Food Safety Authority's forthcoming open-access European Food Composition Database that is expected to be published in mid-2026. |
|
It's probably a wise idea to first do proper unit handling and then get back to this, I simply wanted to start somewhere. Do you know if there is currently and work done regarding this @michael-genson? I will put this on hold until there is some better unit handling. Regarding your more general idea of implementing this with different food database backends, I guess it is definitely possible, but will take way more architectural work to pull of cleanly, because every database has different identifiers for the inredients. |
It's in my (soft) backlog but I'm not currently working on it. Regarding different db backends I'll have to dig into this PR, but I'm fine with picking one standard for now (like you did here). As long as we make it reasonably extensible it should be pretty easy to add on support later. |
What this PR does / why we need it:
This PR comes from the discussion 2748 and tries to implement a first step into the direction of adding nutritional data per ingredient. This would allow users to auto calculate nutritional data of recipes accurately form the ingretients.
I tried to keep the changes very simple for now as to not overload this pull request. The nutritional data is saved but unused. To be usable it would need a connection between the currently existing units and some internal "base units" like "gram", "kilogram" etc. If going that way the user could then select a base unit for each of the individualy created units. All weight units are then convertable and usable. For volume units like "cup" conversion per ingredient would need to be added or could even be pulled from FDC. But this is probably all for a different issue (i would be happy to work on).
Changes in this PR:
/recipe/nutrition/fetch_fda/{fda_id}that uses the FDC_API_KEY to call the API and return the data as nutrition_id/value pairs.foods.vueto allow for input of an FDC ID when creating an ingredient and when editing an ingredient. When the ID got edited the nutrition data is fetched and stored from the FDC API upon confirm of the dialog.Overview table image
Create/edit food widthout FDC ID image
Create/edit food with existing FDC ID image
Which issue(s) this PR fixes:
No issue exists yet, the PR arrises from discussion 2748.
Special notes for your reviewer:
/recipe/ingredient/update_nutrition/{ingredient_id}). But I was not sure how to implement that, so I chose the current solution instead.Testing