-
Notifications
You must be signed in to change notification settings - Fork 58
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
develop #27
base: main
Are you sure you want to change the base?
develop #27
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.
Great job on implementing the core functionality! 🎉 While there are some areas for improvement, such as optimizing database transactions and renaming functions for clarity, these are minor issues that don't critically impact the functionality. Keep up the good work and consider the feedback for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
def get_create(name: str, date: datetime.date, db: Session) -> MovieModel | None: | ||
return db.query(MovieModel).filter(MovieModel.name == name, MovieModel.date == date).first() |
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 function name get_create
is misleading. It suggests both retrieval and creation, but it only retrieves a movie. Consider renaming it to something like get_movie_by_name_and_date
for clarity.
db.commit() | ||
db.refresh(genre) |
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.
Committing within a loop can be inefficient. Consider batching these operations and committing once after the loop to reduce the number of database transactions.
db.commit() | ||
db.refresh(actor) |
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 genres loop, committing within the actors loop can be optimized by batching the operations and committing once after the loop.
db.commit() | ||
db.refresh(language) |
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.
As with the previous loops, consider batching the language operations and committing once after the loop to improve efficiency.
|
||
@router.post("/movies/", response_model=MovieCreateResponse, status_code=201) | ||
def create_movie(movie: MovieCreateRequest, db: Session = Depends(get_db)): | ||
existing_movie = get_create(movie.name, movie.date, db) |
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 function get_create
is misleadingly named as it only retrieves a movie. Consider renaming it to get_movie_by_name_and_date
for clarity.
|
||
db.commit() | ||
|
||
return {"detail": "Movie updated successfully."} |
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 returning the updated movie details in the update_movie
endpoint response. This can be useful for clients to confirm the changes.
|
||
class MovieUpdateRequest(BaseModel): | ||
name: str | None = None | ||
date: str | None = None |
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 date
field in MovieUpdateRequest
should be of type datetime.date | None
instead of str | None
to maintain consistency with other models and ensure proper date validation.
No description provided.