Managing unused foods #3551
Replies: 2 comments 1 reply
-
While there isn't a way to do it in-app, you can use the API for this. Make sure to backup your data before doing this, though. Some pseudo Python code: # Get all foods used in recipes
seen_foods = set()
recipes_data = client.get("/recipes", params={"perPage": -1})
for recipe_summary in recipes_data.items:
slug = recipe_summary["slug"]
recipe = client.get(f"/recipe/{slug}")
for ing in recipe["recipeIngredient"]:
if ing["food"]:
seen_foods.add(ing["food"]["id"])
# Get all foods and store any that were not seen in a recipe
unused_foods = set()
foods_data = client.get("/foods", params={"perPage": -1})
for food in foods_data.items:
if food["id"] not in seen_foods:
unused_foods.add(food["id"])
# Delete all unseen foods
for food_id in unused_foods:
client.delete(f"/foods/{food_id}") |
Beta Was this translation helpful? Give feedback.
-
I wanted to create a new issue about Improvement of management of tags and categories but found this one. I think on the data management page it would be great to have this "clean up" scripts available. Especially when starting using mealie or after longer use, you should be able to clean up. categories, tags might not even be used and could be removed, like foods. For categories and tags it would also be highly valuable for the user to be notified, that they are still in use, if you want to delete them. Only this information wouldnt help though, but you could offer the possibility of choosing other categories, tags right in this dialog from the listbox. |
Beta Was this translation helpful? Give feedback.
-
When setting up mealie, I seeded the food database with the default data provided by mealie. I now find myself wanting to use the food filter more often, however there are a large number of unused foods for which I can search which provides a null search result. Screenshot below.
Is there any way to delete unused foods or hide unused foods from the food search dropdown?
If not, would deleting and reimporting all recopies also import the necessary food items?
Any help gratefully appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions