fix: Use configured server time when calling RepositoryMeals.get_today() method #4734
+8
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
(REQUIRED)
What this PR does / why we need it:
(REQUIRED)
When a user calls the endpoint
/api/households/mealplans/today
, the api uses a hardcoded timezone of UTC to find todays date. This can lead to unexpected results when the user expects the configured timezone to be respected, as it is for the DAILY_SCHEDULE_TIME. To remedy this, I added a timezone argument to the get_today() method of the RepositoryMeals so that when we specifically want to use the configured server time we can, while omitting the flag to respect the UTC timestamps used in the database.tz
argument toget_today
method signature with a default ofUTC
tz
to local tz when callingget_today
method in the GroupMealplanControllertz
to local tz when callingget_today
method increate_timeline_events
Which issue(s) this PR fixes:
(REQUIRED)
Fixes: #4263
Testing
I manually tested this after I setup Mealie and created a mealplan with two entries, one dinner in todays date and then another dinner one day ahead.
I then navigated to the swagger docs page and tested the /api/households/mealplans/today endpoint
I set the TZ environment variables in the docker-compose.yml file to a timezone in the future(i.e. Australia/Sydney) and compared the result to the production build