Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add new labels and foods for en-US language. Update all locale seeding files and seeding logic to parse the new format Only add new labels, units, and foods during seeding (checking against existing names) #4812

Open
wants to merge 5 commits into
base: mealie-next
Choose a base branch
from

Conversation

Cameronwyatt
Copy link

@Cameronwyatt Cameronwyatt commented Jan 1, 2025

What type of PR is this?

(REQUIRED)

  • feature

What this PR does / why we need it:

(REQUIRED)

This is based off of the work in PR #3037. @catduckgnaf did a tremendous amount of work creating the new labels and foods, so credit to them. I modified the format of the en-US.json file based on the feedback provided in that thread, primarily to modify the file so that each key was a label and that there was a value called foods which is a dictionary where each key is the english name of the food and the value is the attributes of the food, including the translated named of the food.

  • Introduced the new en-US.json file for the foods seeding
  • Updated all existing locales for the food file to use the new format
  • Updated the label seeding to read from the foods location instead of its own seed file, since the keys in the JSON dictionary are all of the labels
  • Updated the foods seeding to read from the updated file, looping over each label and all of the foods associated with each. Each food is now associated with a label during creation as well
  • Updated the labels, units, and foods seeding to not create any duplicates, by first querying for all of the current item type and then comparing the name of the new item to see if it already exists. This is a nice QoL change so that clicking "Seed" more than once doesn't leave you with a bunch of duplicate items
  • Updated integration tests to verify against the new number of unique labels (32) and foods (2687)
  • Updates en-US messages to reflect some of the above changes e.g. duplicate items will not be added during seeding

Which issue(s) this PR fixes:

(REQUIRED)

Fixes #1230
Also based on the work in PR #3037

Special notes for your reviewer:

(fill-in or delete this section)

I updated the en-US.json foods seeding file based on the feedback in PR #3037 by @hay-kot.

All food seeding locale files were updated to use the new format

Testing

(fill-in or delete this section)

  • Logged into mealie for the first time and selected the option to seed foods for en-US, verified that worked correctly
  • For a new install with no labels or foods seeded, went to the group data management page and clicked the "Seed" button for the labels and then for the foods
  • For a new install with no labels or foods seeded, went to the group data management page and clicked the "Seed" button for foods and verified they could still be seeded even if the labels were not present
  • Tested with some of the other locales such as es-ES and en-GB as well.
  • Updated the integration tests for seeding and verified those ran successfully

@catduckgnaf
Copy link

I just want to say thank you for the credit and completing what I set out to do. Let me know if I can be of help.

@Cameronwyatt
Copy link
Author

A big thank you to @parumpum as well for their help on discord

@parumpum
Copy link
Contributor

parumpum commented Jan 4, 2025

Thanks for the callout!

A nice complement to this would be a way to run the seed in an Update mode. Not sure if this should maybe be a separate function altogether, or a toggle. That could be up for discussion.

Personally I would like to see if the food already exists, move on to check plural name and label. Update currently empty fields, leave others alone. This wouldn't clobber any existing data or create a bunch of duplicates.

@catduckgnaf
Copy link

Thanks for the callout!

A nice complement to this would be a way to run the seed in an Update mode. Not sure if this should maybe be a separate function altogether, or a toggle. That could be up for discussion.

Personally I would like to see if the food already exists, move on to check plural name and label. Update currently empty fields, leave others alone. This wouldn't clobber any existing data or create a bunch of duplicates.

Well I went through and incorporated all existing, and so many foods and plurals, I can't imagine any missing. I'm not sure how many recipes call for "cacti" but we got that and many others covered. Lol.

…foods seed list instead of their own. Link foods to labels when seeding.
…abel, and unit seeding to query all existing items and then only seed new ones, making it less likely to get duplicates from seeding. Updated messages on group data management page. Updated tests
@Cameronwyatt Cameronwyatt changed the title feat: Add new labels and foods for en-US language. Update seeding logic to parse the new format of the file. Only add new labels, units, and foods during seeding (checking against existing names) feat: Add new labels and foods for en-US language. Update all locale seeding files and seeding logic to parse the new format Only add new labels, units, and foods during seeding (checking against existing names) Jan 13, 2025
@Cameronwyatt Cameronwyatt marked this pull request as ready for review January 13, 2025 02:57
@Cameronwyatt
Copy link
Author

Moved to ready for review - looking forward to any feedback on my first Mealie PR

@Cameronwyatt Cameronwyatt force-pushed the update-seeding branch 2 times, most recently from a7f8b64 to 1d9b981 Compare January 13, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[v1.0.0b] [Task] - Link food labels to foods when importing seed data
3 participants