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

Develop #745

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

Develop #745

wants to merge 6 commits into from

Conversation

b4oody
Copy link

@b4oody b4oody commented Jan 4, 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! There are a few critical issues that need to be addressed before we can approve the pull request. The pagination settings are very restrictive, which might not be suitable for all scenarios, and the condition in get_queryset for MovieViewSet needs to be corrected. Additionally, the tickets_available field requires a proper source or method to compute its value. Once these issues are resolved, your solution 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.

@@ -59,6 +69,7 @@ class MovieSessionListSerializer(MovieSessionSerializer):
cinema_hall_capacity = serializers.IntegerField(
source="cinema_hall.capacity", read_only=True
)
tickets_available = serializers.IntegerField(read_only=True)

Choose a reason for hiding this comment

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

The tickets_available field is marked as read-only but does not have a source or method to calculate its value. Ensure that there is a method or property in the MovieSession model to provide this data.

cinema/views.py Outdated
queryset = Movie.objects.filter(genres__id__in=genres_ids)
elif title:
queryset = Movie.objects.filter(title__contains=title)
if self.action == ("list", "retrieve"):

Choose a reason for hiding this comment

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

The condition if self.action == ("list", "retrieve"): is incorrect. You should check for each action separately, like if self.action in ["list", "retrieve"]:.

Comment on lines +110 to +112
page_size = 1
page_size_query_param = "page_size"
max_page_size = 1

Choose a reason for hiding this comment

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

The pagination settings are very restrictive with a page_size and max_page_size of 1. Ensure this is intentional, as it might not be suitable for all scenarios.

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 many of the issues in your code! 🎉 While there are still some areas that need improvement, your efforts are commendable. Here are a few key points to focus on:

  1. Pagination Settings: The OrderSetPagination class has very restrictive settings with page_size and max_page_size both set to 1. Consider increasing these values to improve user experience by allowing more items per page.

  2. get_queryset in MovieViewSet: Currently, the use of elif statements restricts filtering to one parameter at a time. Switching to if statements will enable filtering by multiple parameters like actors, genres, and title simultaneously.

  3. Transaction Handling in OrderCreateSerializer: Ensure that the ticket creation logic within the create method is robust. While using transaction.atomic is a good practice, make sure to handle any exceptions that might occur during ticket creation to maintain data integrity.

  4. tickets_available Field: This field is marked as read-only but lacks a method to compute its value. Ensure it is properly calculated, possibly by adding a method to compute available tickets based on cinema hall capacity and tickets sold.

Your progress is impressive, and these adjustments will help you further enhance your code. Keep up the great work, and remember to address these critical issues in future iterations to avoid similar problems. Happy coding! 🚀

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

@@ -59,6 +69,7 @@ class MovieSessionListSerializer(MovieSessionSerializer):
cinema_hall_capacity = serializers.IntegerField(
source="cinema_hall.capacity", read_only=True
)
tickets_available = serializers.IntegerField(read_only=True)

Choose a reason for hiding this comment

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

The tickets_available field is marked as read-only, but there is no source or method provided to compute its value. Ensure that this field is properly calculated, possibly by adding a method in the serializer to compute the available tickets based on the cinema hall capacity and the number of tickets already sold.

Comment on lines +131 to +141
@transaction.atomic
def create(self, validated_data):
tickets_data = validated_data.pop("tickets")

order = Order.objects.create(**validated_data)
tickets = [
Ticket(order=order, **ticket_data)
for ticket_data in tickets_data
]
Ticket.objects.bulk_create(tickets)
return order

Choose a reason for hiding this comment

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

Ensure that the ticket creation logic within the create method of OrderCreateSerializer is correctly handling the transaction. The transaction.atomic decorator is used, which is good, but make sure that any potential exceptions during ticket creation are handled to maintain data integrity.

Comment on lines +54 to +59
queryset = Movie.objects.filter(actors__id__in=actors_ids)
elif genres:
genres_ids = [int(str_id) for str_id in genres.split(",")]
queryset = Movie.objects.filter(genres__id__in=genres_ids)
elif title:
queryset = Movie.objects.filter(title__contains=title)

Choose a reason for hiding this comment

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

The current implementation of get_queryset in MovieViewSet uses elif statements, which means only one filter can be applied at a time. Consider using if statements instead to allow filtering by multiple parameters simultaneously, such as actors, genres, and title.

Comment on lines +109 to +111
page_size = 1
page_size_query_param = "page_size"
max_page_size = 1

Choose a reason for hiding this comment

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

The pagination settings in OrderSetPagination are very restrictive, with both page_size and max_page_size set to 1. Consider increasing these values to provide a more user-friendly experience, allowing users to view more items per page.

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