Skip to content

Conversation

cornetto9
Copy link

No description provided.

Msambere and others added 3 commits October 18, 2024 13:37
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.
Copy link
Contributor

@yangashley yangashley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work on Waves 1 and 2! Your project directory is correctly organized and your model/routes look good!

Copy link
Contributor

@yangashley yangashley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!


@planets_bp.get("")
def get_all_planets():
all_params = request.args
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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=[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response_body=[]
response_body = []

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.

3 participants