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

- implemented CRUD #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

- implemented CRUD #49

wants to merge 1 commit into from

Conversation

N1khto
Copy link

@N1khto N1khto commented Feb 25, 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.

Great job on implementing the core functionalities for managing movies! 🎉 While there are a few minor improvements suggested, such as validating the country field with ISO 3166-1 alpha-3 codes and handling exceptions more specifically, these do not significantly impact the overall functionality. Keep up the good work and consider these suggestions for future enhancements! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

per_page: Annotated[int, Query(ge=1, le=20)] = 10,
db: Session = Depends(get_db)
):
movies = db.query(MovieModel).order_by(desc(MovieModel.id)).offset((page - 1) * per_page).limit(per_page)

Choose a reason for hiding this comment

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

Consider checking if the page exceeds total_pages before querying the database to avoid unnecessary queries when the page is out of range.

try:
session.add(instance)
session.commit()
except Exception:

Choose a reason for hiding this comment

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

Catching a general Exception is not recommended. Consider catching specific exceptions like IntegrityError to handle database-related issues more accurately.

@router.post("/movies/", response_model=MovieDetailResponseSchema, status_code=201)
def add_film(movie: MovieCreateResponseSchema, db: Session = Depends(get_db)):
movie_dict = movie.dict()
movie_dict["country"] = get_or_create(db, CountryModel, code=movie_dict["country"])

Choose a reason for hiding this comment

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

Ensure that the country field is linked using the ISO 3166-1 alpha-3 code as specified in the task description. Verify that get_or_create handles this correctly.

status: str
budget: float = Field(ge=0)
revenue: float = Field(ge=0)
country: str

Choose a reason for hiding this comment

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

The country field in MovieCreateResponseSchema should be validated to ensure it uses the ISO 3166-1 alpha-3 code format, as specified in the task description. Consider adding a regex pattern or a custom validator to enforce this format.

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