Пример #1
0
 def list(self, request):
     serializer = NewsFeedSerializer(self.get_queryset(),
                                     context={'request': request},
                                     many=True)
     return Response({
         'newsfeeds': serializer.data,
     },
                     status=status.HTTP_200_OK)
Пример #2
0
 def list(self, request):
     page = self.paginate_queryset(self.get_queryset())
     serializer = NewsFeedSerializer(
         page,
         context={'request': request},
         many=True,
     )
     return self.get_paginated_response(serializer.data)
Пример #3
0
    def list(self, request):
        queryset = NewsFeed.objects.filter(user=self.request.user)
        page = self.paginate_queryset(queryset)

        serializer = NewsFeedSerializer(
            page,
            context={'request': request},
            many=True,
        )
        return self.get_paginated_response(serializer.data)
Пример #4
0
 def list(self, request):
     cached_newsfeeds = NewsFeedService.get_cached_newsfeeds(request.user.id)
     page = self.paginator.paginate_cached_list(cached_newsfeeds, request)
     if page is None:
         queryset = NewsFeed.objects.filter(user=request.user)
         page = self.paginate_queryset(queryset)
     serializer = NewsFeedSerializer(
         page,
         context={'request': request},
         many=True,
     )
     return self.get_paginated_response(serializer.data)
Пример #5
0
 def list(self, request):
     cached_newsfeeds = NewsFeedService.load_newsfeeds_through_cache(
         user_id=request.user.id)
     page = self.paginator.paginate_cached_list(cached_newsfeeds, request)
     # cache not enough, access the db directly for extra
     if not page:
         newsfeeds = NewsFeed.objects.filter(user_id=request.user.id)
         page = self.paginate_queryset(newsfeeds)
     serializer = NewsFeedSerializer(
         page,
         context={'request': request},
         many=True,
     )
     return self.get_paginated_response(serializer.data)
Пример #6
0
    def list(self, request):
        cached_newsfeeds = NewsFeedService.get_cached_newsfeeds(request.user.id)
        page = self.paginator.paginate_cached_list(cached_newsfeeds, request)
        if page is None:
            if GateKeeper.is_switch_on('switch_newsfeed_to_hbase'):
                page = self.paginator.paginate_hbase(HBaseNewsFeed, (request.user.id,), request)
            else:
                queryset = NewsFeed.objects.filter(user=request.user)
                page = self.paginate_queryset(queryset)

        serializer = NewsFeedSerializer(
            page,
            context={'request': request},
            many=True,
        )
        return self.get_paginated_response(serializer.data)
Пример #7
0
    def list(self, request):
        cached_newsfeeds = NewsFeedService.get_cached_newsfeeds(request.user.id)
        page = self.paginator.paginate_cached_list(cached_newsfeeds, request)
        # page is None means the data we get from cache is not enough to satisfy the request
        # so we instead retrieve directly from db
        if page is None:
            if GateKeeper.is_switched_on('switch_newsfeed_to_hbase'):
                page = self.paginator.paginate_hbase(HBaseNewsFeed, (request.user.id,), request)
            else:
                queryset = NewsFeed.objects.filter(user=request.user)
                page = self.paginate_queryset(queryset)

        serializer = NewsFeedSerializer(
            page,
            context={'request': request},
            many=True,
        )
        return self.get_paginated_response(serializer.data)
Пример #8
0
 def list(self, request):
     newsfeeds = self.get_queryset()
     serializer = NewsFeedSerializer(newsfeeds, many=True)
     return Response({
         'newsfeeds': serializer.data,
     }, status=200)
Пример #9
0
 def list(self, request):
     serializer = NewsFeedSerializer(self.get_queryset(), many=True)
     return Response({
         'newsfeeds': serializer.data,
     }, 200)