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

develop #27

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

develop #27

wants to merge 2 commits into from

Conversation

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

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

Comment on lines +20 to +21
def get_create(name: str, date: datetime.date, db: Session) -> MovieModel | None:
return db.query(MovieModel).filter(MovieModel.name == name, MovieModel.date == date).first()

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.

Comment on lines +38 to +39
db.commit()
db.refresh(genre)

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.

Comment on lines +48 to +49
db.commit()
db.refresh(actor)

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.

Comment on lines +58 to +59
db.commit()
db.refresh(language)

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)

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."}

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

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.

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