-
Notifications
You must be signed in to change notification settings - Fork 59
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
Solution #47
base: main
Are you sure you want to change the base?
Solution #47
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your hard work on this project! 🎉 While your code is well-structured and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request.
-
Missing Movie Deletion Endpoint: The task requires an implementation for the movie deletion endpoint in the
routes/movies.py
file. This is crucial for meeting the core requirements of the task. Please add this endpoint to handle DELETE requests to/movies/{movie_id}/
. -
Port Conflict in
docker-compose.yml
: Thedb
service is set to use port5433
on the host. Ensure this port is not already in use to avoid conflicts. If it is, consider changing the host port. -
Error Handling in Database Operations: It's important to add error handling around
db.commit()
operations in your API endpoints to catch potential database errors. This will improve the robustness of your application. -
Safe Access in Pydantic Validator: In the
convert_null_to_string
root validator, usecountry.get('name')
to safely access the 'name' key and avoid potentialKeyError
.
Once these issues are addressed, your code will be in great shape! Keep up the excellent work and don't hesitate to reach out if you have any questions. 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
@@ -5,7 +5,7 @@ services: | |||
env_file: | |||
- .env | |||
ports: | |||
- "5432:5432" | |||
- "5433:5432" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The port mapping for the db
service is set to 5433:5432
. Ensure that port 5433 is not already in use on your host machine to avoid conflicts. If it is, consider using a different host port.
src/routes/movies.py
Outdated
languages=languages | ||
) | ||
db.add(new_movie) | ||
db.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling around the db.commit()
operation to catch potential database errors. This will help in diagnosing issues if the commit fails.
src/routes/movies.py
Outdated
if movie_update.revenue is not None: | ||
movie.revenue = movie_update.revenue | ||
|
||
db.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the create operation, consider adding error handling around the db.commit()
operation to catch potential database errors during the update process.
if not country["name"]: | ||
country["name"] = "null" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convert_null_to_string
root validator assumes that the 'country' dictionary will always have a 'name' key. Consider using country.get('name')
to safely access the 'name' key and avoid potential KeyErrors if the 'country' data is not structured as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Summary
Great job on addressing the previous issues and improving your code! 🎉 Here are some important points from the review:
-
Movie Deletion Endpoint: You've successfully implemented the movie deletion endpoint in the
routes/movies.py
file. It handles DELETE requests correctly and meets the task requirements. -
Port Configuration in
docker-compose.yml
: Although thedocker-compose.yml
file wasn't provided, ensure that the host port5433
for thedb
service is not in conflict with other services. Consider changing it if necessary. -
Error Handling in Database Operations: You've added error handling around database operations, which is a great practice. The
safe_commit
function is a good addition to manage potential database errors. -
Safe Access in Pydantic Validator: You've improved the
convert_null_to_string
root validator by usingcountry.get('name')
to safely access the 'name' key, preventing potentialKeyError
.
Overall, your solution is on the right track! 🚀 While there are a few issues to address, such as ensuring port availability and refining the Pydantic validator, these are learning opportunities. Keep up the great work and continue refining your skills. Remember, addressing critical issues will help you avoid similar problems in the future. Keep pushing forward and learning from these experiences! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -5,7 +5,7 @@ services: | |||
env_file: | |||
- .env | |||
ports: | |||
- "5432:5432" | |||
- "5433:5432" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The db
service is configured to use port 5433
on the host. Ensure this port is not already in use to avoid conflicts. If it is, consider changing the host port.
def convert_null_to_string(cls, values): | ||
country = values.get("country") | ||
if not country["name"]: | ||
country["name"] = "null" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the convert_null_to_string
root validator, use country.get('name')
to safely access the 'name' key and avoid potential KeyError
. This ensures that the code does not break if 'name' is not present in the country
dictionary.
No description provided.