Skip to content

C22 - Kristina Nguyen and Tram Hoang - Phoenix #7

Open
tramhn001 wants to merge 13 commits intoAda-C22:mainfrom
tramhn001:main
Open

C22 - Kristina Nguyen and Tram Hoang - Phoenix #7
tramhn001 wants to merge 13 commits intoAda-C22:mainfrom
tramhn001:main

Conversation

@tramhn001
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Great work so far y'all!

Copy link
Copy Markdown

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Looking good y'all! I left a couple suggestions of things to take forward for future projects.

I like seeing that your team was making commits as you went, in the future I would like to see folks practicing writing more detailed commit messages that talk about the specific files changed, routes added, etc.

distance_from_sun = request_body["distance_from_sun"]
namesake = request_body["namesake"]

new_planet = Planet(name=name, surface_area=surface_area, moons=moons, distance_from_sun=distance_from_sun, namesake=namesake)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Another way to break this line up for length and readability could be:

new_planet = Planet(
    name=name, 
    surface_area=surface_area, 
    moons=moons, 
    distance_from_sun=distance_from_sun, 
    namesake=namesake
)

Comment on lines +10 to +15
request_body = request.get_json()
name = request_body["name"]
surface_area = request_body["surface_area"]
moons = request_body["moons"]
distance_from_sun = request_body["distance_from_sun"]
namesake = request_body["namesake"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What kind of error could be raised by this code? What's a way we could handle it?

if sort_param:
sort_column = getattr(Planet, sort_param, None)
if sort_column:
query = query.order_by(asc(sort_column) if order_param == "asc" else desc(sort_column))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How could we break up this line for length?

Comment on lines +40 to +45
distance_from_sun_param = request.args.get("distance_from_sun")
if distance_from_sun_param:
query = query.where(Planet.distance_from_sun <= distance_from_sun_param)
query = query.order_by(Planet.id)

planets = db.session.scalars(query)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since adding the order_by isn't tightly related to filtering by distance_from_sun_param, I'd consider adding space between those statements:

    distance_from_sun_param = request.args.get("distance_from_sun")
    if distance_from_sun_param:
        query = query.where(Planet.distance_from_sun <= distance_from_sun_param)
    
    query = query.order_by(Planet.id)
    planets = db.session.scalars(query)

@@ -0,0 +1,69 @@
def test_get_all_planets_with_no_records(client):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thinking about our routes vs our tests, what gaps do you see in the test suite? What functions could we add tests for to get better test coverage for the project?

query = db.select(Planet)

if sort_param:
sort_column = getattr(Planet, sort_param, None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice solution for flexibility on what folks can sort by!

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