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

Feat/timeline event for mealplans #2050

Conversation

michael-genson
Copy link
Collaborator

What type of PR is this?

(REQUIRED)

  • feature

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 our env.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)

meal plans now create recipe timeline events and update the recipe's last made date

@michael-genson
Copy link
Collaborator Author

michael-genson commented Jan 22, 2023

Looks like the backend failures were only the network requests for that one recipe site that's having issues. If I find time I'll get a PR in to get rid of those requests. Hopefully by the time you get to this PR you can just re-run the workflow and tests will pass. Locally I've seen it work a few times (but I definitely want to get it to work here because I don't have postgres set up locally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants