Open
Conversation
Added an endpoint to return a lis of all planet_routes
Created endpoints for a specific planet and handled errors for non-integer input and invalid integers.
yangashley
reviewed
Oct 23, 2024
Contributor
yangashley
left a comment
There was a problem hiding this comment.
Nice work on Waves 1 and 2! Your project directory is correctly organized and your model/routes look good!
Add create_new_planet() and get_all_planets() with their corresponding routes and HTTP methods. Additonally created get_one_planet()
yangashley
reviewed
Nov 1, 2024
|
|
||
| @planets_bp.get("") | ||
| def get_all_planets(): | ||
| all_params = request.args |
Contributor
There was a problem hiding this comment.
Could also call all_params something like query_params
Comment on lines
+91
to
+92
| planet.name = request_body['name'] | ||
| planet.description = request_body['description'] |
Contributor
There was a problem hiding this comment.
Since this is a PUT route, I'd expect to see a way to update the rest of this model's attributes (size, moons, has_flag)
| query = query.filter(Planet.moons >= all_params.get("moons")) | ||
|
|
||
| if all_params.get("has_flag"): | ||
| query =query.where(Planet.has_flag == all_params.get("has_flag")) |
Contributor
There was a problem hiding this comment.
Suggested change
| query =query.where(Planet.has_flag == all_params.get("has_flag")) | |
| query = query.where(Planet.has_flag == all_params.get("has_flag")) |
|
|
||
| planets = db.session.scalars(query) | ||
|
|
||
| response_body=[] |
Contributor
There was a problem hiding this comment.
Suggested change
| response_body=[] | |
| response_body = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.