Skip to content

feat: add per-100g column to recipe nutrition label - #4748

Open
JvandeLocht wants to merge 1 commit into
TandoorRecipes:developfrom
JvandeLocht:NutritionPer100g
Open

feat: add per-100g column to recipe nutrition label#4748
JvandeLocht wants to merge 1 commit into
TandoorRecipes:developfrom
JvandeLocht:NutritionPer100g

Conversation

@JvandeLocht

Copy link
Copy Markdown

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.

  • 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
grafik

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
@KPKluge

KPKluge commented Jul 15, 2026

Copy link
Copy Markdown

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:

  • water evaporates during cooking or baking
  • rice, pasta, or legumes absorb water
  • ingredients may be drained
  • bones, shells, cooking liquid, or other parts may be removed

Example:

  • calculated ingredient weight: 1,800 g
  • actual finished recipe yield: 1,500 g

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:

  1. Automatically calculate the ingredient weight as proposed in this PR.
  2. Add an optional editable field such as “Finished yield weight” or “Recipe yield weight”.
  3. Use the manually entered value for the per-100-g calculation when present.
  4. Fall back to the automatically calculated ingredient weight when no manual value is set.
  5. Scale the manually entered yield proportionally when the recipe is scaled.

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.

@JvandeLocht

Copy link
Copy Markdown
Author

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.
If we would later scale the whole recipe to compensate for the weight difference of a specific food item, after evaporation or absoprtion of fluids, we would also scale the food items that didnt loose any weight.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants