Skip to content

Commit

Permalink
Logic to add new plural foods
Browse files Browse the repository at this point in the history
  • Loading branch information
Choromanski committed Oct 1, 2024
1 parent 1b0e5b0 commit c1e73fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions mealie/repos/seed/seeders.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,16 @@ def get_file(self, locale: str | None = None) -> pathlib.Path:
def load_data(self, locale: str | None = None) -> Generator[SaveIngredientFood, None, None]:
file = self.get_file(locale)

seed_foods: dict[str, str] = json.loads(file.read_text(encoding="utf-8"))
for food in set(seed_foods.values()):
seed_foods_names = set()
for food in json.loads(file.read_text(encoding="utf-8")).values():
if food["name"] in seed_foods_names:
continue

seed_foods_names.add(food["name"])
yield SaveIngredientFood(
group_id=self.repos.group_id,
name=food,
name=food["name"],
plural_name=food.get("plural_name"),
description="",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_seed_invalid_locale(api_client: TestClient, unique_user: TestUser):


def test_seed_foods(api_client: TestClient, unique_user: TestUser):
CREATED_FOODS = 220
CREATED_FOODS = 215
database = unique_user.repos

# Check that the foods was created
Expand Down

0 comments on commit c1e73fe

Please sign in to comment.