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" #33

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

"Solution" #33

wants to merge 3 commits into from

Conversation

TIgor22
Copy link

@TIgor22 TIgor22 commented Jan 26, 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.


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:

  1. Import Statement Issue: The import statement on line 1 is incorrect. Ensure you use from math import ceil instead of from math import ceil /.

  2. Country Filtering: The get_or_create_country function should filter by CountryModel.name instead of CountryModel.code to align with how genres and actors are handled.

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

  4. Model Consistency: The status field in the MovieRead model should use MovieStatusEnum 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

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

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.

Comment on lines +135 to +137
db_movie.genres = genres
db_movie.actors = actors
db_movie.languages = languages

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.

date: datetime.date
score: float
overview: str
status: str

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.

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

  1. Country Filtering: The get_or_create_country function should filter by CountryModel.name instead of CountryModel.code. This change is crucial to maintain consistency with how other entities like genres and actors are handled.

  2. Model Consistency: Ensure that the status field in both the MovieUpdate and MovieRead models uses MovieStatusEnum. 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

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

Comment on lines +70 to +71
def get_or_create_country(country: str, db: Session = Depends(get_db)):
db_country = db.query(CountryModel).filter(CountryModel.code == country).first()

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.

Comment on lines +133 to +135
db_movie.genres = genres
db_movie.actors = actors
db_movie.languages = languages

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,

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.

date: Optional[datetime.date] = None
score: Optional[float] = None
overview: Optional[str] = None
status: Optional[str] = None

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.

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