mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-02 22:13:11 -05:00
* upgrade sqlalchemy to 2.0 * rewrite all db models to sqla 2.0 mapping api * fix some importing and typing weirdness * fix types of a lot of nullable columns * remove get_ref methods * fix issues found by tests * rewrite all queries in repository_recipe to 2.0 style * rewrite all repository queries to 2.0 api * rewrite all remaining queries to 2.0 api * remove now-unneeded __allow_unmapped__ flag * remove and fix some unneeded cases of "# type: ignore" * fix formatting * bump black version * run black * can this please be the last one. okay. just. okay. * fix repository errors * remove return * drop open API validator --------- Co-authored-by: Sören Busch <fleshgolem@gmx.net>
21 lines
734 B
Python
21 lines
734 B
Python
from datetime import date
|
|
from uuid import UUID
|
|
|
|
from sqlalchemy import select
|
|
|
|
from mealie.db.models.group import GroupMealPlan
|
|
from mealie.schema.meal_plan.new_meal import ReadPlanEntry
|
|
|
|
from .repository_generic import RepositoryGeneric
|
|
|
|
|
|
class RepositoryMeals(RepositoryGeneric[ReadPlanEntry, GroupMealPlan]):
|
|
def by_group(self, group_id: UUID) -> "RepositoryMeals":
|
|
return super().by_group(group_id)
|
|
|
|
def get_today(self, group_id: UUID) -> list[ReadPlanEntry]:
|
|
today = date.today()
|
|
stmt = select(GroupMealPlan).filter(GroupMealPlan.date == today, GroupMealPlan.group_id == group_id)
|
|
plans = self.session.execute(stmt).scalars().all()
|
|
return [self.schema.from_orm(x) for x in plans]
|