mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
feat: Add Additional Plan To Eat Columns To Import (#3776)
This commit is contained in:
parent
a9b40cd862
commit
0e520ba43c
@ -58,7 +58,6 @@ class PlanToEatMigrator(BaseMigrator):
|
||||
MigrationAlias(key="prepTime", alias="Prep Time"),
|
||||
MigrationAlias(key="performTime", alias="Cook Time"),
|
||||
MigrationAlias(key="totalTime", alias="Total Time"),
|
||||
MigrationAlias(key="tags", alias="Tags", func=split_by_comma),
|
||||
MigrationAlias(key="dateAdded", alias="Created At", func=lambda x: x[: x.find(" ")]),
|
||||
]
|
||||
|
||||
@ -77,11 +76,34 @@ class PlanToEatMigrator(BaseMigrator):
|
||||
|
||||
return cleaner.clean_nutrition(nut_dict)
|
||||
|
||||
def _get_categories_from_row(self, row: dict) -> list[str]:
|
||||
"""Parses various category-like columns into categories"""
|
||||
|
||||
categories: list[str] = []
|
||||
columns = ["Course", "Cuisine"]
|
||||
for column in columns:
|
||||
value = get_value_as_string_or_none(row, column)
|
||||
if value:
|
||||
categories.append(value)
|
||||
|
||||
return categories
|
||||
|
||||
def _get_tags_from_row(self, row: dict) -> list[str]:
|
||||
tag_str = get_value_as_string_or_none(row, "Tags")
|
||||
tags = split_by_comma(tag_str) or []
|
||||
main_ingredient = get_value_as_string_or_none(row, "Main Ingredient")
|
||||
if main_ingredient:
|
||||
tags.append(main_ingredient)
|
||||
|
||||
return tags
|
||||
|
||||
def _process_recipe_row(self, row: dict) -> dict:
|
||||
"""Reads a single recipe's row, parses its nutrition, and converts it to a dictionary"""
|
||||
"""Reads a single recipe's row, merges columns, and converts the row to a dictionary"""
|
||||
|
||||
recipe_dict: dict = row
|
||||
|
||||
recipe_dict["recipeCategory"] = self._get_categories_from_row(row)
|
||||
recipe_dict["tags"] = self._get_tags_from_row(row)
|
||||
recipe_dict["nutrition"] = self._parse_recipe_nutrition_from_row(row)
|
||||
|
||||
return recipe_dict
|
||||
|
Loading…
x
Reference in New Issue
Block a user