1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-06 14:05:21 +02:00

Feature/automated meal planner (#939)

* cleanup oversized buttons

* add get all by category function to reciep repos

* fix shopping-list can_merge logic

* use randomized data for testing

* add random getter to repository for meal-planner

* add stub route for random meals

* cleanup global namespace

* add rules database type

* fix type

* add plan rules schema

* test plan rules methods

* add mealplan rules controller

* add new repository

* update frontend types

* formatting

* fix regression

* update autogenerated types

* add api class for mealplan rules

* add tests and fix bugs

* fix data returns

* proof of concept rules editor

* add tag support

* remove old group categories

* add tag support

* implement random by rules api

* change snack to sides

* remove incorrect typing

* split repo for custom methods

* fix query and use and_ clause

* use repo function

* remove old test

* update changelog
This commit is contained in:
Hayden 2022-02-07 19:03:11 -09:00 committed by GitHub
parent 40d1f586cd
commit d1024e272d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1153 additions and 175 deletions

View file

@ -1,4 +1,5 @@
# GENERATED CODE - DO NOT MODIFY BY HAND
from .meal import *
from .new_meal import *
from .plan_rules import *
from .shopping_list import *

View file

@ -13,7 +13,12 @@ class PlanEntryType(str, Enum):
breakfast = "breakfast"
lunch = "lunch"
dinner = "dinner"
snack = "snack"
side = "side"
class CreatRandomEntry(CamelModel):
date: date
entry_type: PlanEntryType = PlanEntryType.dinner
class CreatePlanEntry(CamelModel):

View file

@ -0,0 +1,63 @@
import datetime
from enum import Enum
from fastapi_camelcase import CamelModel
from pydantic import UUID4
class Category(CamelModel):
id: int
name: str
slug: str
class Config:
orm_mode = True
class Tag(Category):
class Config:
orm_mode = True
class PlanRulesDay(str, Enum):
monday = "monday"
tuesday = "tuesday"
wednesday = "wednesday"
thursday = "thursday"
friday = "friday"
saturday = "saturday"
sunday = "sunday"
unset = "unset"
@staticmethod
def from_date(date: datetime.date):
"""Returns the enum value for the date passed in"""
try:
return PlanRulesDay[(date.strftime("%A").lower())]
except KeyError:
return PlanRulesDay.unset
class PlanRulesType(str, Enum):
breakfast = "breakfast"
lunch = "lunch"
dinner = "dinner"
unset = "unset"
class PlanRulesCreate(CamelModel):
day: PlanRulesDay = PlanRulesDay.unset
entry_type: PlanRulesType = PlanRulesType.unset
categories: list[Category] = []
tags: list[Tag] = []
class PlanRulesSave(PlanRulesCreate):
group_id: UUID4
class PlanRulesOut(PlanRulesSave):
id: UUID4
class Config:
orm_mode = True

View file

@ -24,6 +24,7 @@ app_dirs = get_app_dirs()
class RecipeTag(CamelModel):
id: int = 0
name: str
slug: str
@ -78,7 +79,7 @@ class RecipeSummary(CamelModel):
perform_time: Optional[str] = None
description: Optional[str] = ""
recipe_category: Optional[list[RecipeTag]] = []
recipe_category: Optional[list[RecipeCategory]] = []
tags: Optional[list[RecipeTag]] = []
tools: list[RecipeTool] = []
rating: Optional[int]

View file

@ -15,11 +15,11 @@ class UnitFoodBase(CamelModel):
class CreateIngredientFood(UnitFoodBase):
label_id: UUID4 = None
label: MultiPurposeLabelSummary = None
class IngredientFood(CreateIngredientFood):
id: int
label: MultiPurposeLabelSummary = None
class Config:
orm_mode = True
@ -86,5 +86,4 @@ class IngredientRequest(CamelModel):
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary
CreateIngredientFood.update_forward_refs()
IngredientFood.update_forward_refs()