mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 10:13:32 -04:00 
			
		
		
		
	fix: Ingredient Parser Drops Units Sometimes (#6150)
This commit is contained in:
		| @@ -161,12 +161,15 @@ class ABCIngredientParser(ABC): | ||||
|             ingredient.ingredient.unit = unit_match | ||||
|  | ||||
|         # Parser might have wrongly split a food into a unit and food. | ||||
|         if isinstance(ingredient.ingredient.food, CreateIngredientFood) and isinstance( | ||||
|             ingredient.ingredient.unit, CreateIngredientUnit | ||||
|         ): | ||||
|             if food_match := self.data_matcher.find_food_match( | ||||
|                 f"{ingredient.ingredient.unit.name} {ingredient.ingredient.food.name}" | ||||
|             ): | ||||
|         food_is_matched = bool(ingredient.ingredient.food and ingredient.ingredient.food.id) | ||||
|         unit_is_matched = bool(ingredient.ingredient.unit and ingredient.ingredient.unit.id) | ||||
|         food_name = ingredient.ingredient.food.name if ingredient.ingredient.food else "" | ||||
|         unit_name = ingredient.ingredient.unit.name if ingredient.ingredient.unit else "" | ||||
|  | ||||
|         if not food_is_matched and not unit_is_matched and food_name and unit_name: | ||||
|             food_match = self.data_matcher.find_food_match(f"{unit_name} {food_name}") | ||||
|  | ||||
|             if food_match: | ||||
|                 ingredient.ingredient.food = food_match | ||||
|                 ingredient.ingredient.unit = None | ||||
|  | ||||
|   | ||||
| @@ -181,7 +181,6 @@ def parsed_ingredient_data( | ||||
|             id="stalk bell peppers, cut in pieces", | ||||
|         ), | ||||
|         pytest.param("red pepper flakes", 0, "", "red pepper flakes", "", id="red pepper flakes"), | ||||
|         pytest.param("1 red pepper flakes", 1, "", "red pepper flakes", "", id="1 red pepper flakes"), | ||||
|         pytest.param("1 bell peppers", 1, "", "bell peppers", "", id="1 bell peppers"), | ||||
|         pytest.param("1 stalk bell peppers", 1, "Stalk", "bell peppers", "", id="1 big stalk bell peppers"), | ||||
|         pytest.param("a big stalk bell peppers", 0, "Stalk", "bell peppers", "", id="a big stalk bell peppers"), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user