Любимые страницы

This commit is contained in:
iriska-gri committed 2023-12-21 12:55:18 +03:00
1 parent 1b1220b9e7
commit e1e41d9256
3 files changed
+42 -13

No files matched your search

+8 -6
View File
@@ -63,13 +63,15 @@ class Counter(ListAPIView):
return Response(res)
# class SelectedLinksAPIView(ListAPIView):
class SelectedLinksAPIView(ListAPIView):
# def get(self, request):
# user = User.objects.get(username=self.request.user)
# res = CountVisitor.objects.values('page','fullPath','ico').filter(user_id=user).annotate(Sum('count')).exclude(fullPath='/')
# sort = res.order_by('-count__sum')[:20]
def get(self, request):
user = User.objects.get(username=self.request.user)
res = CountVisitor.objects.values('pages__page','pages__fullPath','pages__ico').filter(user_id=user).annotate(Sum('count')).exclude(pages__fullPath='/')
# res = CountVisitor.objects.values('pages__page','pages__fullPath','pages__ico').filter(user_id=user).annotate(Sum('count')).exclude(fullPath='/')
sort = res.order_by('-count__sum')[:20]
# return Response(sort)
return Response(sort)