Skip to content

Commit

Permalink
Merge branch 'mealie-next' into fix/update-pre-commit-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-genson authored Dec 18, 2024
2 parents c73e1fa + f8e4c7f commit 196fb60
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 101 deletions.
4 changes: 2 additions & 2 deletions mealie/repos/repository_meals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@


class RepositoryMeals(HouseholdRepositoryGeneric[ReadPlanEntry, GroupMealPlan]):
def get_today(self) -> list[ReadPlanEntry]:
def get_today(self, tz=UTC) -> list[ReadPlanEntry]:
if not self.household_id:
raise Exception("household_id not set")

today = datetime.now(tz=UTC).date()
today = datetime.now(tz=tz).date()
stmt = select(GroupMealPlan).filter(
GroupMealPlan.date == today, GroupMealPlan.household_id == self.household_id
)
Expand Down
4 changes: 3 additions & 1 deletion mealie/routes/households/controller_mealplan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import date
from functools import cached_property

from dateutil.tz import tzlocal
from fastapi import APIRouter, Depends, HTTPException

from mealie.core.exceptions import mealie_registered_exceptions
Expand Down Expand Up @@ -115,7 +116,8 @@ def create_one(self, data: CreatePlanEntry):

@router.get("/today")
def get_todays_meals(self):
return self.repo.get_today()
local_tz = tzlocal()
return self.repo.get_today(tz=local_tz)

@router.post("/random", response_model=ReadPlanEntry)
def create_random_meal(self, data: CreateRandomEntry):
Expand Down
4 changes: 3 additions & 1 deletion mealie/services/scheduler/tasks/create_timeline_events.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import UTC, datetime, time, timedelta

from dateutil.tz import tzlocal
from pydantic import UUID4
from sqlalchemy.orm import Session

Expand Down Expand Up @@ -29,7 +30,8 @@ def _create_mealplan_timeline_events_for_household(
recipes_to_update: dict[UUID4, RecipeSummary] = {}
recipe_id_to_slug_map: dict[UUID4, str] = {}

mealplans = repos.meals.get_today()
local_tz = tzlocal()
mealplans = repos.meals.get_today(tz=local_tz)
for mealplan in mealplans:
if not (mealplan.recipe and mealplan.user_id):
continue
Expand Down
Loading

0 comments on commit 196fb60

Please sign in to comment.