-
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
"Solution" #33
base: main
Are you sure you want to change the base?
"Solution" #33
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 implementation is on the right track, there are a few critical issues that need to be addressed before we can approve the pull request:
-
Import Statement Issue: The import statement on line 1 is incorrect. Ensure you use
from math import ceil
instead offrom math import ceil /
. -
Country Filtering: The
get_or_create_country
function should filter byCountryModel.name
instead ofCountryModel.code
to align with how genres and actors are handled. -
Associating Entities: After creating a movie, genres, actors, and languages should be added to the
db_movie
before committing to ensure they are correctly associated with the movie. -
Model Consistency: The
status
field in theMovieRead
model should useMovieStatusEnum
for consistency and proper validation against enum values.
Addressing these issues will ensure that the code functions as expected and meets the task requirements. Keep up the great work, and I'm confident you'll nail these changes! 😊
✨ 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.
@@ -1,12 +1,228 @@ | |||
from fastapi import APIRouter, Depends, HTTPException, Query | |||
from math import ceil |
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 import statement from math import ceil
is incorrect. It should be from math import ceil
instead of from math import ceil /
.
|
||
|
||
def get_or_create_country(country: str, db: Session = Depends(get_db)): | ||
db_country = db.query(CountryModel).filter(CountryModel.code == country).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 get_or_create_country
function filters by CountryModel.code
, but it seems like it should filter by CountryModel.name
instead, similar to how genres and actors are handled.
db_movie.genres = genres | ||
db_movie.actors = actors | ||
db_movie.languages = languages |
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.
After creating the movie, you should add the genres, actors, and languages to the db_movie
before committing. The current code adds them after the commit, which might not associate them correctly with the movie.
src/schemas/movies.py
Outdated
date: datetime.date | ||
score: float | ||
overview: str | ||
status: str |
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 status
field in MovieRead
is defined as str
, but in MovieCreate
, it is MovieStatusEnum
. Consider using MovieStatusEnum
for consistency and to ensure the status is validated against the enum values.
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 addressing most of the issues in your code! 🎉 Your efforts in correcting the import statement and ensuring that genres, actors, and languages are properly associated with the movie before committing are commendable. However, there are a few critical areas that still need attention:
-
Country Filtering: The
get_or_create_country
function should filter byCountryModel.name
instead ofCountryModel.code
. This change is crucial to maintain consistency with how other entities like genres and actors are handled. -
Model Consistency: Ensure that the
status
field in both theMovieUpdate
andMovieRead
models usesMovieStatusEnum
. This will provide consistency across your models and ensure proper validation against enum values.
These adjustments are important for the functionality and consistency of your code. While the decision is to approve your pull request to help you move forward with your learning, it's essential to address these issues in future iterations to avoid similar problems. Keep up the good work, and continue to learn and improve from these experiences! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -1,12 +1,228 @@ | |||
from fastapi import APIRouter, Depends, HTTPException, Query | |||
from math import ceil |
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 import statement is incorrect. It should be from math import ceil
instead of from math import ceil /
.
def get_or_create_country(country: str, db: Session = Depends(get_db)): | ||
db_country = db.query(CountryModel).filter(CountryModel.code == country).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 get_or_create_country
function should filter by CountryModel.name
instead of CountryModel.code
to align with how genres and actors are handled.
db_movie.genres = genres | ||
db_movie.actors = actors | ||
db_movie.languages = languages |
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.
Ensure that genres, actors, and languages are added to the db_movie
before committing to ensure they are correctly associated with the movie.
date=db_movie.date, | ||
score=db_movie.score, | ||
overview=db_movie.overview, | ||
status=db_movie.status, |
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 status
field in the MovieRead
model should use MovieStatusEnum
for consistency and proper validation against enum values.
src/schemas/movies.py
Outdated
date: Optional[datetime.date] = None | ||
score: Optional[float] = None | ||
overview: Optional[str] = None | ||
status: Optional[str] = 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 status
field in the MovieUpdate
model should use MovieStatusEnum
instead of str
for consistency with the MovieCreate
and MovieRead
models. This will ensure proper validation against enum values.
No description provided.