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

Implemented CRUD #43

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

Implemented CRUD #43

wants to merge 4 commits into from

Conversation

kleotan901
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! There are a few critical issues that need to be addressed before we can approve the pull request. Specifically, the get_or_create_country function has a filtering issue that could lead to incorrect behavior, and the update_film function might unintentionally overwrite existing data with None. Additionally, the remove_film function's response handling should be adjusted for a 204 status code. Please make these changes, and feel free to reach out if you need any help! Keep up the great work! 😊

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

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Your Pull Request has been approved! 🎉 You've made significant improvements to the code, addressing the key issues from the previous review. Here's a summary of the review:

  • get_or_create_country function: You've resolved the filtering issue, ensuring the function correctly retrieves or creates a country by its country_code.

  • update_film function: Great job on ensuring that fields are not overwritten with None values. This is crucial for maintaining data integrity. Continue to handle all fields similarly to prevent unintended data loss.

  • remove_film function: The function correctly returns a 204 status code without a response body, aligning with standard API practices. Make sure this behavior fits your overall API design.

Your code now meets the task requirements and constraints. While the decision is to approve, please review the comments to further enhance your code. Addressing any remaining issues will help you avoid similar problems in the future. Keep up the great work and continue learning from these experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

Comment on lines +111 to +121
@router.delete("/movies/{movie_id}", response_model=MovieDetail)
def remove_film(movie_id: int, db: Session = Depends(get_db)):
db_film = get_movie_by_id(db, movie_id)
if not db_film:
raise HTTPException(
status_code=404,
detail="Movie with the given ID was not found."
)
db.delete(db_film)
db.commit()
return Response(status_code=204)

Choose a reason for hiding this comment

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

The remove_film function correctly returns a 204 status code, indicating successful deletion without a response body. Ensure that this behavior aligns with your API design requirements.

Comment on lines +124 to +161
@router.patch("/movies/{movie_id}", response_model=MovieDetail)
def update_film(
movie_id: int,
movie: MovieUpdate,
db: Session = Depends(get_db)
):
db_film = get_movie_by_id(db, movie_id)
if not db_film:
raise HTTPException(
status_code=404,
detail="Movie with the given ID was not found."
)
db_film.name = movie.name
db_film.date = movie.date if movie.date is not None else db_film.date
db_film.score = (
movie.score if movie.score is not None
else db_film.score
)
db_film.overview = (
movie.overview
if movie.overview is not None
else db_film.overview
)
db_film.status = (
movie.status if movie.status is not None
else db_film.status
)
db_film.budget = (
movie.budget if movie.budget is not None
else db_film.budget
)
db_film.revenue = (
movie.revenue if movie.revenue is not None
else db_film.revenue
)
db.commit()
db.refresh(db_film)
return JSONResponse(content={"detail": "Movie updated successfully."})

Choose a reason for hiding this comment

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

The update_film function correctly checks for None values before updating fields, preventing unintended overwrites. Ensure that all fields are handled similarly to maintain data integrity.

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.

2 participants