-
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 #28
base: main
Are you sure you want to change the base?
Solution #28
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.
Sorry, the pull request review was unsuccessful for the following reasons:
Warning
Something went wrong while processing the review.
[CODE: 3]
If the issue is within your control, please address it.
The next review attempt will automatically launch in 1 hour.
If you believe this is an error or need assistance, please contact the support team.
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! There are a few critical issues that need to be addressed before we can approve the pull request. Please correct the import statement for timedelta
, ensure the create_movie
function returns the expected detailed response, and make the status
field in MovieUpdateSchema
optional. Once these changes are made, your code will be in great shape! 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.
@@ -1,12 +1,178 @@ | |||
from datetime import date, timedelta |
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 for timedelta
is incorrect. It should be from datetime import timedelta
instead of using a division operator.
src/routes/movies.py
Outdated
return MovieCreateSchema( | ||
name=new_movie.name, | ||
date=new_movie.date, | ||
score=new_movie.score, | ||
overview=new_movie.overview, | ||
status=new_movie.status, | ||
budget=new_movie.budget, | ||
revenue=new_movie.revenue, | ||
country=new_movie.country.code, | ||
genres=[genre.name for genre in new_movie.genres], | ||
actors=[actor.name for actor in new_movie.actors], | ||
languages=[language.name for language in new_movie.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.
The create_movie
function should return a detailed response including the movie's ID and related entities (country, genres, actors, languages) as specified in the task description. Ensure the response structure matches the expected format.
src/schemas/movies.py
Outdated
status: MovieStatusEnum = Field( | ||
None, description="string (Released | Post Production | In Production)" | ||
) |
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 MovieUpdateSchema
should be optional. Ensure it is correctly defined as Optional[MovieStatusEnum]
to align with the rest of the optional fields in this schema.
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 the issues from the previous review! 🎉 The import statement for timedelta
is now correctly included, and the create_movie
function returns a detailed response with all necessary fields. The status
field in MovieUpdateSchema
is also optional, as required. While the code meets the task requirements, remember to review the comments to improve your code further. Addressing critical issues, like import errors and response structures, is essential for functionality. Keep up the good work and continue learning from these experiences! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
@@ -1,12 +1,179 @@ | |||
from datetime import date, timedelta |
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 for timedelta
is incorrect. It should be from datetime import date, timedelta
without the slash.
return MovieCreateSchema( | ||
id=new_movie.id, | ||
name=new_movie.name, | ||
date=new_movie.date, | ||
score=new_movie.score, | ||
overview=new_movie.overview, | ||
status=new_movie.status, | ||
budget=new_movie.budget, | ||
revenue=new_movie.revenue, | ||
country=new_movie.country.code, | ||
genres=[genre.name for genre in new_movie.genres], | ||
actors=[actor.name for actor in new_movie.actors], | ||
languages=[language.name for language in new_movie.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.
The create_movie
function should return a detailed response, possibly using MovieDetailResponseSchema
instead of MovieCreateSchema
, to ensure all necessary details are included in the response.
movie.date = movie_data.date if movie_data.date else movie.date | ||
movie.score = movie_data.score if movie_data.score else movie.score | ||
movie.overview = movie_data.overview if movie_data.overview else movie.overview | ||
movie.status = movie_data.status if movie_data.status else 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.
Ensure that the status
field in MovieUpdateSchema
is optional. If it is not, this line might cause issues when updating a movie without providing a status.
src/routes/movies.py
Outdated
country = db.query(CountryModel).filter_by(code=movie.country).first() | ||
if not country: | ||
country = CountryModel(code=movie.country) | ||
db.add(country) | ||
db.flush() | ||
|
||
genres = [] | ||
for genre_name in movie.genres: | ||
genre = db.query(GenreModel).filter_by(name=genre_name).first() | ||
if not genre: | ||
genre = GenreModel(name=genre_name) | ||
db.add(genre) | ||
db.flush() | ||
genres.append(genre) | ||
|
||
actors = [] | ||
for actor_name in movie.actors: | ||
actor = db.query(ActorModel).filter_by(name=actor_name).first() | ||
if not actor: | ||
actor = ActorModel(name=actor_name) | ||
db.add(actor) | ||
db.flush() | ||
actors.append(actor) | ||
|
||
languages = [] | ||
for language_name in movie.languages: | ||
language = db.query(LanguageModel).filter_by(name=language_name).first() | ||
if not language: | ||
language = LanguageModel(name=language_name) | ||
db.add(language) | ||
db.flush() | ||
languages.append(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.
Code is not following DRY principle
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.
LGTM
No description provided.