fixed 0 servings

This commit is contained in:
vabene1111
2025-10-11 11:47:10 +02:00
parent 680ae39201
commit d6da5688af
2 changed files with 3 additions and 2 deletions

View File

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

View File

@@ -229,7 +229,7 @@ const selectedAiProvider = ref<undefined | AiProvider>(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)
})
/**