feat: add per-100g column to recipe nutrition label - #4748
Conversation
Add a "per 100g" column to the property view alongside the existing "per serving" and "total" columns. - FoodPropertyHelper: compute total_weight_grams from ingredient weight conversions during calculate_recipe_properties() - RecipeSerializer: add food_weight read-only field exposing the computed weight (skipped on create, like food_properties) - PropertyView.vue: add per_100g column with serving weight subtitle - API client (Recipe.ts, PatchedRecipe.ts): add foodWeight field
|
Thanks for implementing nutrition values per 100 g. This is a very useful addition. Would it be possible to support an optional manually entered recipe yield weight as well? The sum of the ingredient weights is often different from the actual weight of the finished recipe. For example:
Example:
In this case, the nutritional values per 100 g should be calculated using the finished yield of 1,500 g rather than the original ingredient weight. A possible implementation could be:
This would make the feature accurate for cooked meals, bread, cakes, sauces, soups, and similar recipes while preserving the convenient automatic calculation as the default. |
|
I thought a bit about your proposal and I dont think this is the right approach. The nutrition values are basically calculated by a weighted sum of the respective foods. I think to accomplish your goal we would need to set the yield weight of each food item individually, but I dont think that fits in the scope of this PR. |
To be upfront, I have done most of this with GLM 5.2, but I tried my best to strip the final version of all reimplementations of existing helpers and such.
I have tested this on my live proxmox lxc install of tandoor and found no side effects, during adding or editing of new and or existing recipes. Furthermore I consumed the API with SparkyFitness and could not find any difference in its behaviour.
I have read and signed the CLA.
Add a "per 100g" column to the property view alongside the existing "per serving" and "total" columns.