Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
feat: Leverage Mealie Food Aliases to Match Foods (#35)
Browse files Browse the repository at this point in the history
* remove deprecated settings

* added aliases to food store

* removed more deprecated settings
  • Loading branch information
michael-genson authored Jun 11, 2024
1 parent 5ee853c commit 61de475
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
8 changes: 0 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,9 @@
},
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Default",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
Expand Down
16 changes: 0 additions & 16 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.linting.mypyArgs": [
"--follow-imports=silent",
"--show-column-numbers",
"--disallow-untyped-defs",
"--disallow-untyped-calls",
],
"python.linting.pylintArgs": [
"--enable=W0614"
],
"explorer.fileNesting.enabled": true,
"python.formatting.provider": "black",
"isort.args": [
"--profile",
"black"
],
"explorer.fileNesting.patterns": {
"package.json": "package-lock.json, yarn.lock, .eslintrc.js, tsconfig.json, .prettierrc, .editorconfig",
"pyproject.toml": "poetry.lock, alembic.ini, .pylintrc, .flake8, .bumpversion.cfg",
Expand Down
11 changes: 11 additions & 0 deletions AppLambda/src/models/mealie.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,23 @@ def __str__(self) -> str:
return self.name


class UnitFoodAlias(MealieBase):
name: str


class UnitFoodBase(MealieBase):
name: str
plural_name: str | None = None
description: str = ""
extras: dict | None = {}

aliases: list[UnitFoodAlias] | None = None
"""
List of aliases for this unit/food
Only available in v1.0.0-RC2 and later
"""


class Unit(UnitFoodBase):
id: str | None
Expand Down
9 changes: 8 additions & 1 deletion AppLambda/src/services/mealie.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ def recipe_store(self) -> dict[str, MealieRecipe]:
def food_store(self) -> dict[str, Food]:
"""Dictionary of { food.name.lower(): Food }"""

return {food.name.lower(): food for food in self._client.get_all_foods()}
store: dict[str, Food] = {}
all_foods = self._client.get_all_foods()
for food in all_foods:
store[food.name.lower()] = food
for alias in food.aliases or []:
store[alias.name.lower()] = food

return store

@cached_property
def label_store(self) -> dict[str, Label]:
Expand Down

0 comments on commit 61de475

Please sign in to comment.