@@ -101,6 +102,7 @@
+
diff --git a/src/front/src/views/HomePage.vue b/src/front/src/views/HomePage.vue
index af34985ed..dd8344dc8 100644
--- a/src/front/src/views/HomePage.vue
+++ b/src/front/src/views/HomePage.vue
@@ -1,19 +1,19 @@
-
-
+
+
-
-
+
+
-
+
@@ -26,29 +26,27 @@
>
-
+
-
-
-
@@ -57,8 +55,8 @@
-
-
+
+
-
-
-
-
@@ -129,19 +123,20 @@
const favorit = ref([])
const toggle = ref(null)
- pagecounter()
const accountStore = useAccountStore()
+ pagecounter()
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/models.py b/src/watcher/models.py
index 3a6710433..4b0f0138e 100644
--- a/src/watcher/models.py
+++ b/src/watcher/models.py
@@ -1,27 +1,38 @@
from django.db import models
+from django.conf import settings
from accounts.models import User
# Create your models here.
import pandas as pd
-class CountVisitor(models.Model):
- page = models.CharField(db_index=True, max_length=255)
- visitdate = models.DateField()
- user = models.ForeignKey(User, null=True, blank=True, on_delete=models.PROTECT)
- count = models.IntegerField(default=0)
- fullPath = models.CharField(max_length=255)
+class Pages(models.Model):
+ page = models.CharField(max_length=255)
+ fullPath = models.CharField(max_length=255)
ico = models.CharField(verbose_name='Иконка', max_length=150, null=True, blank=True)
def __str__(self):
- return str(self.page)
+ return str(self.page)
+
+
+class CountVisitor(models.Model):
+ # page = models.CharField(db_index=True, max_length=255)
+ pages = models.ForeignKey(Pages, on_delete=models.PROTECT, related_name='get_pages', verbose_name='Страница', null=True)
+ visitdate = models.DateField()
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.PROTECT, verbose_name='Пользователь', null=True, blank=True)
+ count = models.IntegerField(default=0)
+ # fullPath = models.CharField(max_length=255)
+ # ico = models.CharField(verbose_name='Иконка', max_length=150, null=True, blank=True)
+
+ def __str__(self):
+ return str(self.pages)
- class Meta:
+ # class Meta:
- constraints = [
- models.UniqueConstraint(fields=['page', 'user', 'visitdate', 'fullPath', 'ico'], name='unique appversion')
- ]
+ # constraints = [
+ # models.UniqueConstraint(fields=['page', 'user', 'visitdate', 'fullPath', 'ico'], name='unique appversion')
+ # ]
\ No newline at end of file
diff --git a/src/watcher/urls.py b/src/watcher/urls.py
index 261002e4a..0d21fb9ce 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 f71de607a..4bc2328e9 100644
--- a/src/watcher/views.py
+++ b/src/watcher/views.py
@@ -16,49 +16,60 @@ class Counter(ListAPIView):
permission_classes = (AllowAny,)
serializer_class = CountSerializer
- def get(self, request):
- res = CountVisitor.objects.values('page').annotate(Sum('count'))
- users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
- outuser = DictEmployee.objects.values('login', 'fio')
- pUser = pd.DataFrame.from_records(users)
- pOutUser = pd.DataFrame.from_records(outuser)
- h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
+# def get(self, request):
+# res = CountVisitor.objects.values('page').annotate(Sum('count'))
+# users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
+# outuser = DictEmployee.objects.values('login', 'fio')
+# pUser = pd.DataFrame.from_records(users)
+# pOutUser = pd.DataFrame.from_records(outuser)
+# h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
- for x in users:
- if x['user__username'] is not None:
- x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
- else:
- x['user__username'] = 'Анонимные'
+# for x in users:
+# if x['user__username'] is not None:
+# x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
+# else:
+# x['user__username'] = 'Анонимные'
- return Response({"pages":res, "users": users})
+# return Response({"pages":res, "users": users})
def post(self, request):
+
+ print('ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd')
+
+
+
+
myfullPath = request.data['fullPath']
if "?" in myfullPath:
myfullPath= myfullPath.split("?")[0]
- # print(fullPath.split("?")[0], '---request.data-------------------------')
+ print(request.data['page'], 'request.data[page]-------')
+ page, create = Pages.objects.get_or_create(page=request.data['page'], fullPath=myfullPath, ico=request.data['ico'])
+
if request.data['user__id'] is not None:
- watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),page=request.data['page'], visitdate=date.today(), fullPath=myfullPath, ico=request.data['ico'])
- else:
- watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, page=request.data['page'], visitdate=date.today(), fullPath=myfullPath, ico=request.data['ico'])
+ watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),pages=page, visitdate=date.today())
+ print('if ----------------------------')
+ else:
+ watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, pages=page, visitdate=date.today())
watch.count+=1
watch.save()
-
- res = {"totalvisit": CountVisitor.objects.filter(page=request.data['page']).aggregate(Sum('count'))['count__sum'],
- "visittoday":CountVisitor.objects.filter(visitdate=date.today(), page=request.data['page']).aggregate(Sum('count'))['count__sum'],
- "uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), page=request.data['page']).count()
+
+ res = {"totalvisit": CountVisitor.objects.filter(pages=page.id).aggregate(Sum('count'))['count__sum'],
+ "visittoday":CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).aggregate(Sum('count'))['count__sum'],
+ "uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).count()
}
+
+
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('page','fullPath','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
From a22195e9480961822e2cae10985a246e506719b1 Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:55:18 +0300
Subject: [PATCH 17/32] =?UTF-8?q?=D0=9B=D1=8E=D0=B1=D0=B8=D0=BC=D1=8B?=
=?UTF-8?q?=D0=B5=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/front/src/views/HomePage.vue | 39 +++++++++++++++++++++++++++-----
src/watcher/urls.py | 2 +-
src/watcher/views.py | 14 +++++++-----
3 files changed, 42 insertions(+), 13 deletions(-)
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
From 9a59ce9f5a2ed0ed38b970d3a93ce9d5b114a29e Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Thu, 21 Dec 2023 12:57:47 +0300
Subject: [PATCH 18/32] =?UTF-8?q?=D0=A1=20=D1=82=D1=83=D0=BB=D1=82=D0=B8?=
=?UTF-8?q?=D0=BF=D0=B0=D0=BC=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/front/src/views/HomePage.vue | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/front/src/views/HomePage.vue b/src/front/src/views/HomePage.vue
index a243dc29e..6705e09cd 100644
--- a/src/front/src/views/HomePage.vue
+++ b/src/front/src/views/HomePage.vue
@@ -74,10 +74,20 @@
divided
variant="outlined"
>
-
+
+
+
+
+
From 4dd7e27ff727dcabfa2fe9b1dcf49d60c52f52d5 Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Thu, 21 Dec 2023 13:55:41 +0300
Subject: [PATCH 19/32] =?UTF-8?q?=D0=A1=D1=82=D0=B0=D1=82=D0=B8=D1=81?=
=?UTF-8?q?=D1=82=D0=B8=D0=BA=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/front/src/views/AboutPortalPage.vue | 8 ++++--
src/front/src/views/HomePage.vue | 22 +-------------
src/watcher/views.py | 38 ++++++++++---------------
3 files changed, 21 insertions(+), 47 deletions(-)
diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue
index e759508f9..4f37c2b08 100644
--- a/src/front/src/views/AboutPortalPage.vue
+++ b/src/front/src/views/AboutPortalPage.vue
@@ -7,7 +7,9 @@
-
+
+ {{visiting}}
+
+
diff --git a/src/watcher/views.py b/src/watcher/views.py
index a874fea67..c8bb685f8 100644
--- a/src/watcher/views.py
+++ b/src/watcher/views.py
@@ -16,39 +16,33 @@ class Counter(ListAPIView):
permission_classes = (AllowAny,)
serializer_class = CountSerializer
-# def get(self, request):
-# res = CountVisitor.objects.values('page').annotate(Sum('count'))
-# users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
-# outuser = DictEmployee.objects.values('login', 'fio')
-# pUser = pd.DataFrame.from_records(users)
-# pOutUser = pd.DataFrame.from_records(outuser)
-# h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
+ def get(self, request):
+ res = CountVisitor.objects.values('pages__page').filter(visitdate__year='2023', visitdate__month='01', visitdate__day='21').annotate(Sum('count'))
+ # users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
+ # outuser = DictEmployee.objects.values('login', 'fio')
+ # pUser = pd.DataFrame.from_records(users)
+ # pOutUser = pd.DataFrame.from_records(outuser)
+ # h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
-# for x in users:
-# if x['user__username'] is not None:
-# x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
-# else:
-# x['user__username'] = 'Анонимные'
+ # for x in users:
+ # if x['user__username'] is not None:
+ # x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
+ # else:
+ # x['user__username'] = 'Анонимные'
-# return Response({"pages":res, "users": users})
+ # return Response({"pages":res, "users": users})
+ return Response(res)
def post(self, request):
-
- print('ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd')
-
-
-
-
myfullPath = request.data['fullPath']
if "?" in myfullPath:
myfullPath= myfullPath.split("?")[0]
- print(request.data['page'], 'request.data[page]-------')
+
page, create = Pages.objects.get_or_create(page=request.data['page'], fullPath=myfullPath, ico=request.data['ico'])
if request.data['user__id'] is not None:
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),pages=page, visitdate=date.today())
- print('if ----------------------------')
else:
watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, pages=page, visitdate=date.today())
watch.count+=1
@@ -58,8 +52,6 @@ class Counter(ListAPIView):
"visittoday":CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).aggregate(Sum('count'))['count__sum'],
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).count()
}
-
-
return Response(res)
From 791d0751027a2b11c8e695c3e7a0fa7c9ffcbc89 Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Thu, 21 Dec 2023 16:18:16 +0300
Subject: [PATCH 20/32] =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=BD=D1=8B=D0=B5=20?=
=?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=81=D1=82=D0=B0=D1=82=D0=B8=D1=81=D1=82?=
=?UTF-8?q?=D0=B8=D0=BA=D0=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/front/src/views/AboutPortalPage.vue | 4 ++--
src/watcher/views.py | 13 ++++++++-----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue
index 4f37c2b08..093af0b90 100644
--- a/src/front/src/views/AboutPortalPage.vue
+++ b/src/front/src/views/AboutPortalPage.vue
@@ -67,8 +67,7 @@