Feat/timeline event for mealplans #2050
Merged
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)
This PR makes it so when a meal plan is scheduled for today (as a daily scheduled task), a recipe timeline event is created and the
last_made
property on the recipe is updated (when applicable).Because timeline events require a user, I had to add the user id to the meal plan table (as a foreign key). I kept it optional in the schema for compatibility, but when meal plans are created they now add the user automatically.
Which issue(s) this PR fixes:
(REQUIRED)
Resolves discussion #2037
Special notes for your reviewer:
(fill-in or delete this section)
I used batch ops in the migration and manually named the foreign key relationship per the alembic docs (and this SO thread). Seems like this is the right way to do it, but it's not something I've come across before so let me know if there's a better way.
The solution says to mark
render_as_batch=True
but all that does is change how alembic auto-generates the migration file, so I didn't actually change ourenv.py
config since I don't know if it has other implications (I changed it, generated the file, then changed it back). Might be worth changing permanently, but the workaround is easy enough for development purposes.Testing
(fill-in or delete this section)
Added a bunch of backend tests. I didn't test the frontend because of that frontend dev issue mentioned in Discord, but this is purely backend anyway.
Release Notes
(REQUIRED)