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

Implement CRUD #10

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

Implement CRUD #10

wants to merge 2 commits into from

Conversation

Atikiho
Copy link

@Atikiho Atikiho commented Jan 20, 2025

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.

Great job on implementing the CRUD operations and API routes for the movie database! 🎉 Your code meets the task requirements and constraints effectively. While there are some minor issues related to validation, error handling, and response models, they don't significantly impact the functionality. Keep up the good work, and consider the feedback for future improvements! 😊

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



def create_movie(movie_data, db: Session = Depends(get_db)):
if not 0 <= movie_data.score <= 100:

Choose a reason for hiding this comment

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

The condition not 0 <= movie_data.score <= 100 should include the boundary values. Consider changing it to not (0 <= movie_data.score <= 100) to ensure scores of 0 and 100 are considered valid.

status_code=404,
detail="Movie with the given ID was not found."
)
if movie_data.score and not 0 < movie_data.score < 100:

Choose a reason for hiding this comment

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

The condition not 0 < movie_data.score < 100 should include the boundary values. Consider changing it to not (0 <= movie_data.score <= 100) to ensure scores of 0 and 100 are considered valid.

Comment on lines +186 to +187
detail=f"A movie with the name '{movie.name}'"
f" and release date '{movie.date}' already exists."

Choose a reason for hiding this comment

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

There is a potential issue with the error message here. It uses movie.name and movie.date, which might not reflect the intended values if the movie data is being updated. Consider using movie_data.name and movie_data.date instead.

Comment on lines +19 to +23
if not movie:
raise HTTPException(
status_code=404,
detail="Movie with the given ID was not found."
)

Choose a reason for hiding this comment

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

The check for if not movie: is redundant here because the get_movie function already raises an HTTPException if the movie is not found. You can remove this check to avoid unnecessary code duplication.

):
return get_movies(page, per_page, db)


Choose a reason for hiding this comment

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

The response model for the POST request should not be MovieCreate as it represents the input data structure. Consider using a model that represents the created movie, such as DetailedMovies or another appropriate schema.

id: int
name: str
date: datetime.date
score: float

Choose a reason for hiding this comment

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

The score field in MovieSchema should be consistent with the validation logic in the CRUD operations. Ensure that the score is validated to be between 0 and 100, inclusive.

Comment on lines +62 to +64
revenue: float
status: str
budget: float

Choose a reason for hiding this comment

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

Consider making revenue, status, and budget optional in DetailedMovies if they can be absent or unknown in some cases. This would align with the flexibility provided in MovieUpdate.

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