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

Sea Turtles - Esther A. & Danielle W. #11

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

estherannorzie
Copy link

No description provided.

Copy link

@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 y'all! I've left a few comments, please reach out if you have any questions on the feedback 🙂

app/routes.py Outdated Show resolved Hide resolved
app/routes.py Outdated Show resolved Hide resolved

return jsonify(to_dict(planet))

def validate_planet(planet_id):

Choose a reason for hiding this comment

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

I'd consider renaming this function. To me, validate_planet sounds like it should return a true/false based on if the planet passed as a parameter is valid. What name might better describe what the function is doing?

app/routes.py Outdated Show resolved Hide resolved
app/routes.py Outdated Show resolved Hide resolved
Copy link

@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.

Nice looking code Esther & Danielle! I've left a few comments, feel free to reply here or message me on Slack if you have questions on the feedback 🙂

app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql+psycopg2://postgres:postgres@localhost:5432/solar_system_development'
else:
app.config["TESTING"] = True
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

Choose a reason for hiding this comment

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

The line app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False is duplicated in both parts of the if/else. We could move that line to either above or below the if/else, so it only needs to be written once.

planet = Planet.query.get(planet_id)

if not planet:
abort(make_response({"message": f"planet id {planet_id} not found"}, 404))

Choose a reason for hiding this comment

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

For a little extra code reuse, the abort calls in this function could also use the helper jsonify_message:

abort(jsonify_message({"message": f"planet id {planet_id} not found"}, 404))


db.session.commit()

return jsonify_message(f"Planet succesfully updated. {planet.to_dict()}")

Choose a reason for hiding this comment

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

I'd consider returning the planet name in the message like in create_planet, or if you want to return all the data for the planet, maybe separating that into a different key/value pair in the response. Placing the dictionary contents inside a message string sounds like it might not be easy to read.

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