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?
What this PR does / why we need it:
Calling /api/recipes with
loadFood: false
(or any other endpoint that lists recipes) would lead to an interesting case, where all the recipe ingredients are not eager loaded any more but pydantic would still try to fill therecipe_ingredient
field of the response model in orm mode, i.e. sqlalchemy will generate a new lazy-loading ingredient query for every single recipe. I assume this issue gets even worse, if you use ingredient foods/units, but I have not tested this any further.I created a new response model that explicitly has the ingredients and removed them from the normal recipe summary, so only /api/recipes with loadFood enabled should ever try to load them now and all other endpoints that list recipes should behave the correct way.
Additionally - as discussed on discord - I also moved all validation from RecipeSummary to Recipe, since they are never needed for output validation. They are still needed on Recipe, otherwise all the migration tests will fail (and I assume the migrations wont work anymore)
This hopefully should improve performance for loading recipe pages considerably, especially for slower devices that really seem to have problems here
Which issue(s) this PR fixes:
No explicit issue exists AFAIK, but it has been raised on discord a few times
Testing
Ran all automated tests and also tried listing everything on the locally running frontend
Release Notes