Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use configured server time when calling RepositoryMeals.get_today() method #4734

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading