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

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

Solution #659

wants to merge 3 commits into from

Conversation

pashawarganov
Copy link

No description provided.

cinema/views.py Outdated
queryset = self.queryset.select_related("movie")

if self.action == "list":
queryset = (

Choose a reason for hiding this comment

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

This is a bit of a weird hyphenation, I think it would be better to do it like this
queryset = queryset.annotate(
...
)

cinema/views.py Outdated
queryset = self.queryset.filter(user=self.request.user)

if self.action == "list":
queryset = (

Choose a reason for hiding this comment

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

This is a bit of a weird hyphenation, I think it would be better to do it like this

queryset = queryset.prefetch_related(
...
)

cinema/models.py Outdated
Comment on lines 88 to 93
def validate_row_and_seat(
row: int,
seat: int,
movie_session: MovieSession,
error_to_raise
):

Choose a reason for hiding this comment

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

Annotations, everywhere :) they still exist)

order = Order.objects.create(**validated_data)
for ticket in tickets:
Ticket.objects.create(order=order, **ticket)
return order

Choose a reason for hiding this comment

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

In create/update/delete function you don't need to return anything



class TicketListSerializer(TicketSerializer):
movie_session = MovieSessionListSerializer(many=False, read_only=True)

Choose a reason for hiding this comment

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

many by default is False

cinema/views.py Outdated
@@ -43,11 +63,35 @@ def get_serializer_class(self):

return MovieSerializer

def get_queryset(self):
queryset = self.queryset

Choose a reason for hiding this comment

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

Resolve N+1 problem

cinema/views.py Outdated
Comment on lines 132 to 135
class OrderSetPagination(PageNumberPagination):
page_size = 2
page_size_query_param = "page_size"
max_page_size = 20

Choose a reason for hiding this comment

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

Put pagination better in separate file

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.

4 participants