diff --git a/src/front/src/views/HomePage.vue b/src/front/src/views/HomePage.vue index dd8344dc8..a243dc29e 100644 --- a/src/front/src/views/HomePage.vue +++ b/src/front/src/views/HomePage.vue @@ -57,11 +57,37 @@ - + + + + + + + + + @@ -128,15 +154,16 @@ onMounted(() => { favoritLinks() + }) const favoritLinks = () => { - // axiosApiInstance.get(`api/watcher/selectedlinks/`) - // .then(data => { - // favorit.value = data.data - // }) + axiosApiInstance.get(`api/watcher/selectedlinks/`) + .then(data => { + favorit.value = data.data + }) } diff --git a/src/watcher/urls.py b/src/watcher/urls.py index 0d21fb9ce..261002e4a 100644 --- a/src/watcher/urls.py +++ b/src/watcher/urls.py @@ -3,7 +3,7 @@ from .views import * urlpatterns = [ path('counter/', Counter.as_view(),name="CountVisitors"), - # path('selectedlinks/', SelectedLinksAPIView.as_view(),name="SelectedLinks") + path('selectedlinks/', SelectedLinksAPIView.as_view(),name="SelectedLinks") # path('', views.Watchuser.as_view()), selectedlinks diff --git a/src/watcher/views.py b/src/watcher/views.py index 4bc2328e9..a874fea67 100644 --- a/src/watcher/views.py +++ b/src/watcher/views.py @@ -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) \ No newline at end of file