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

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

solution #1093

wants to merge 10 commits into from

Conversation

artemIg1990
Copy link

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! However, there are a few critical issues that need to be addressed before we can approve the pull request. These issues impact the functionality and core requirements of the code:

  1. Typographical Errors:

    • In models.py, the Movie model has a typo in the field name gerne, which should be genre.
    • In movie.py, the create_movie function has a typo: gernes should be genres.
    • In movie_session.py, there are typos in get_movies_sessions (objecta should be objects) and get_movie_session_by_id (movie_sessin_id should be movie_session_id).
  2. Incorrect Method Usage:

    • The get_movie_by_id function should use .get() instead of .filter() to retrieve a single Movie instance.
  3. Persistence Issues:

    • The create_cinema_hall function does not save the new CinemaHall instance to the database, which is necessary for persistence.
  4. Filter Application:

    • The filter method is not being applied correctly in both get_movies_sessions and get_movies. You need to assign the result of the filter method back to the variable to actually apply the filters.

Please address these issues to ensure the code functions as expected. Once these changes are made, we can proceed with the approval. Keep up the great work, and don't hesitate to reach out if you need any help! 😊

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

db/models.py Outdated
title = models.CharField(max_length=255, unique=True)
description = models.TextField()
actors = models.ManyToManyField(Actor)
gerne = models.ManyToManyField(Genre)

Choose a reason for hiding this comment

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

There is a typo here: gerne should be genre. This will cause an error when trying to access this field.

Comment on lines 9 to 14
def create_cinema_hall(hall_name: str,
hall_rows: int,
hall_seats_in_row: int) -> CinemaHall:
return CinemaHall(hall_name,
hall_rows,
hall_seats_in_row)

Choose a reason for hiding this comment

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

The create_cinema_hall function creates a CinemaHall instance but does not save it to the database. You should call the save() method on the CinemaHall instance to persist it to the database.

Comment on lines 9 to 11
movies.filter(genres__in=genres_ids)
if actors_ids:
movies.filter(actors__in=actors_ids)

Choose a reason for hiding this comment

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

The filter method is not being applied correctly. You need to assign the result of the filter method back to the movies variable, like movies = movies.filter(...), to actually apply the filters.



def get_movie_by_id(movie_id) -> Movie:
return Movie.objects.filter(id=movie_id)

Choose a reason for hiding this comment

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

The get_movie_by_id function should use get() instead of filter() to retrieve a single instance. Using filter() returns a QuerySet, not a single Movie instance.

new_movie = Movie.objects.create(title=movie_title,
description=movie_description)
if genres_ids:
new_movie.gernes.set(genres_ids)

Choose a reason for hiding this comment

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

There is a typo here: gernes should be genres. This will cause an error when trying to set the genres for the movie.



def get_movies_sessions(session_date: datetime.date = None) -> QuerySet:
sessions_list = MovieSession.objecta.all()

Choose a reason for hiding this comment

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

There is a typo here: objecta should be objects. This will cause an error when trying to retrieve all movie sessions.

def get_movies_sessions(session_date: datetime.date = None) -> QuerySet:
sessions_list = MovieSession.objecta.all()
if session_date:
sessions_list.filter(show_time__date=session_date)

Choose a reason for hiding this comment

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

The filter method is not being applied correctly. You need to assign the result of the filter method back to the sessions_list variable, like sessions_list = sessions_list.filter(...), to actually apply the filter.



def get_movie_session_by_id(movie_session_id: int) -> MovieSession:
return MovieSession.objects.get(id=movie_sessin_id)

Choose a reason for hiding this comment

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

There is a typo here: movie_sessin_id should be movie_session_id. This will cause an error when trying to retrieve a movie session by ID.

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 effort on addressing some of the issues from the previous review! 🎉 While the Pull Request is approved to help you move forward with your learning, there are still some critical issues that need attention to ensure the code functions as expected:

  1. Typographical Errors:

    • In services/movie.py, the create_movie function still contains a typo: gernes should be corrected to genres.
  2. Incorrect Method Usage:

    • The get_movie_by_id function in services/movie.py should use .get() instead of .filter() to retrieve a single Movie instance. This change will ensure that an exception is raised if the movie is not found, which is typically the desired behavior.
  3. Persistence Issues:

    • The create_cinema_hall function in services/cinema_hall.py does not currently save the new CinemaHall instance to the database. Ensure you call the save() method on the instance or use CinemaHall.objects.create() for persistence.
  4. Filter Application:

    • In services/movie_session.py, the filter method is not applied correctly in get_movies_sessions. Assign the result of the filter method back to sessions_list to apply the filter.
    • Similarly, in services/movie.py, ensure the filter method is applied correctly in get_movies by assigning the result back to movies.

These issues are crucial for the functionality of your code, so please address them in future iterations. Keep up the good work, and continue learning from these experiences to improve your coding skills! 🚀

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

Comment on lines 9 to 14
def create_cinema_hall(hall_name: str,
hall_rows: int,
hall_seats_in_row: int) -> CinemaHall:
return CinemaHall(hall_name,
hall_rows,
hall_seats_in_row)

Choose a reason for hiding this comment

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

The create_cinema_hall function should save the new CinemaHall instance to the database. You can do this by calling the save() method on the instance before returning it. This will ensure the cinema hall is persisted in the database.

Comment on lines 9 to 11
movies.filter(genres__in=genres_ids)
if actors_ids:
movies.filter(actors__in=actors_ids)

Choose a reason for hiding this comment

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

The filter method is not being applied correctly in the get_movies function. You need to assign the result of the filter method back to the movies variable to actually apply the filters. For example: movies = movies.filter(genres__in=genres_ids).



def get_movie_by_id(movie_id: int) -> Movie:
return Movie.objects.filter(id=movie_id)

Choose a reason for hiding this comment

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

The get_movie_by_id function should use .get() instead of .filter() to retrieve a single Movie instance. This will raise an exception if the movie is not found, which is typically the desired behavior when fetching a single object by ID.

new_movie = Movie.objects.create(title=movie_title,
description=movie_description)
if genres_ids:
new_movie.gernes.set(genres_ids)

Choose a reason for hiding this comment

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

There is a typo in the create_movie function. The method new_movie.gernes.set(genres_ids) should be new_movie.genres.set(genres_ids) to match the corrected field name in the Movie model.

def get_movies_sessions(session_date: datetime.date = None) -> QuerySet:
sessions_list = MovieSession.objects.all()
if session_date:
sessions_list.filter(show_time__date=session_date)

Choose a reason for hiding this comment

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

The filter method is not being applied correctly in the get_movies_sessions function. You need to assign the result of the filter method back to the sessions_list variable to actually apply the filter. For example: sessions_list = sessions_list.filter(show_time__date=session_date).

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