mealie-recipes / mealie

Mealie is a self hosted recipe manager and meal planner with a RestAPI backend and a reactive frontend application built in Vue for a pleasant user experience for the whole family. Easily add recipes into your database by providing the url and mealie will automatically import the relevant data or add a family recipe with the UI editor
https://docs.mealie.io
GNU Affero General Public License v3.0
5.59k stars 608 forks source link

feat: Auto-label new shopping list items #3800

Closed michael-genson closed 1 day ago

michael-genson commented 2 days ago

What type of PR is this?

(REQUIRED)

What this PR does / why we need it:

(REQUIRED)

This PR automatically adds a label to a shopping list item if it isn't provided. We already did similar work for this a while ago for the ingredient parser, so I extracted that into its own service and used it here.

We don't want to autocorrect the user's input (since we could be wrong), so we only use the result to choose the label, rather than assign the food. See below, where I spell "oranges" wrong; the proper label is assigned, but the word is still as-written:

2024-06-26_10h54_11

This only works on item creation, so if a user decides "nah I don't want a label on this" and removes it, it stays removed. In general I don't know why you wouldn't want to try to apply a label to an item, hence the PR. This is similar to other shopping lists which auto-categorize your items (e.g. the Alexa shopping list does this).

Which issue(s) this PR fixes:

(REQUIRED)

N/A

Special notes for your reviewer:

(fill-in or delete this section)

I've actually been using this logic for a year or so now as a part of my Unified Shopping List. I've been meaning to get it into Mealie. Now that Amazon is killing all shopping list integrations for Alexa, I felt now was a good time to get this in here.

Testing

(fill-in or delete this section)

Added tests for the new feature and manually tested the parser to make sure I didn't break anything with the refactor.