From d6da5688af773f251d9f473f621da43d33f6b9e4 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 11 Oct 2025 11:47:10 +0200 Subject: [PATCH] fixed 0 servings --- cookbook/helper/recipe_url_import.py | 3 ++- vue3/src/components/display/RecipeView.vue | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index 300b26b2c..e9404447e 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -72,7 +72,8 @@ def get_from_scraper(scrape, request): # assign servings attributes try: # dont use scrape.yields() as this will always return "x servings" or "x items", should be improved in scrapers directly - servings = scrape.schema.data.get('recipeYield') or 1 + # max(x,1) to prevent 0 servings which breaks scaling + servings = max(scrape.schema.data.get('recipeYield') or 1, 1) except Exception: servings = 1 diff --git a/vue3/src/components/display/RecipeView.vue b/vue3/src/components/display/RecipeView.vue index 347536f94..fcb43ba95 100644 --- a/vue3/src/components/display/RecipeView.vue +++ b/vue3/src/components/display/RecipeView.vue @@ -229,7 +229,7 @@ const selectedAiProvider = ref(useUserPreferenceStore(). * factor for multiplying ingredient amounts based on recipe base servings and user selected servings */ const ingredientFactor = computed(() => { - return servings.value / ((recipe.value.servings != undefined) ? recipe.value.servings : 1) + return servings.value / ((recipe.value.servings != undefined) ? Math.max(recipe.value.servings, 1) : 1) }) /**