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

Solution #28

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

Solution #28

wants to merge 10 commits into from

Conversation

Den-k0
Copy link

@Den-k0 Den-k0 commented Jan 22, 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.

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.

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.

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

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.

Comment on lines 120 to 132
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],
)

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.

Comment on lines 97 to 99
status: MovieStatusEnum = Field(
None, description="string (Released | Post Production | In Production)"
)

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.

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

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.

Comment on lines +120 to +133
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],
)

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

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.

Comment on lines 70 to 101
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)

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

@Den-k0 Den-k0 requested a review from AnyoneClown January 29, 2025 10:12
Copy link

@AnyoneClown AnyoneClown left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants