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

not solution, i need check because have a little problem with git #662

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

Conversation

Ivan-Shakhman
Copy link

if u see only one commit just reject it

Copy link

@mihavryliuk mihavryliuk left a comment

Choose a reason for hiding this comment

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

You need to withit qna((

Copy link

@mihavryliuk mihavryliuk left a comment

Choose a reason for hiding this comment

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

ok

@@ -35,6 +45,10 @@ class MovieListSerializer(MovieSerializer):
many=True, read_only=True, slug_field="full_name"
)

class Meta:
model = Movie
fields = MovieSerializer.Meta.fields + ("genres", "actors")

Choose a reason for hiding this comment

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

You inherit from MovieSerializer and it already has genres and actors fields in Meta

cinema/views.py Outdated
@@ -11,7 +15,7 @@
MovieSessionListSerializer,
MovieDetailSerializer,
MovieSessionDetailSerializer,
MovieListSerializer,
MovieListSerializer, OrderSerializer, OrderListSerializer,

Choose a reason for hiding this comment

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

continue with each import on new line

cinema/views.py Outdated
return [int(num) for num in query.split(",")]

def get_queryset(self):
query_set = self.queryset

Choose a reason for hiding this comment

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

How do you solve N+1 problem here?

cinema/views.py Outdated
@@ -56,3 +91,48 @@ def get_serializer_class(self):
return MovieSessionDetailSerializer

return MovieSessionSerializer

def get_queryset(self):
query_set = (

Choose a reason for hiding this comment

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

you already defined queryset with annotations above - just access it through self.

return query_set


class OrderPagination(PageNumberPagination):

Choose a reason for hiding this comment

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

would be better structure to put pagination in a spearate file

pagination_class = OrderPagination

def get_queryset(self):
return self.queryset.filter(user=self.request.user)

Choose a reason for hiding this comment

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

N+1 problem not solved here

Copy link

@Arsen-hrynevych Arsen-hrynevych left a comment

Choose a reason for hiding this comment

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

ok


from cinema.models import Genre, Actor, CinemaHall, Movie, MovieSession
from cinema.models import Genre, Actor, CinemaHall, Movie, MovieSession, Order

Choose a reason for hiding this comment

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

If importing more than two items, it is better to write them on separate lines. This improves readability and maintenance of the code.

Example:

From taxi.models import (
Driver,
Manufacturer,
Car
)
Read more about topic here

@@ -6,7 +6,7 @@
ActorViewSet,
CinemaHallViewSet,
MovieViewSet,
MovieSessionViewSet,
MovieSessionViewSet, OrderViewSet,

Choose a reason for hiding this comment

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

Inconsistent. Just move to a new line.

@@ -15,6 +15,7 @@
router.register("cinema_halls", CinemaHallViewSet)
router.register("movies", MovieViewSet)
router.register("movie_sessions", MovieSessionViewSet)
router.register("orders", OrderViewSet)

urlpatterns = [path("", include(router.urls))]

Choose a reason for hiding this comment

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

You could simplify it to urlpatterns = router.urls

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