Счетчик
This commit is contained in:
1 parent
339f854494
commit
1b1220b9e7
11 files changed
+108
-76
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="d-flex h-100">
|
<div class="d-flex h-100 ">
|
||||||
|
|
||||||
<v-card
|
<v-card
|
||||||
v-if="t_daily.length > 0"
|
v-if="t_daily.length > 0"
|
||||||
@@ -19,7 +19,11 @@
|
|||||||
elevation="0"
|
elevation="0"
|
||||||
>
|
>
|
||||||
<v-card class="h-100 text-center text-black_grey bg-black_and_white">
|
<v-card class="h-100 text-center text-black_grey bg-black_and_white">
|
||||||
<v-card-title class="statstyle py-0 text-overline font-weight-bold bg-black_and_white">
|
<v-card-title
|
||||||
|
class="statstyle py-0
|
||||||
|
text-xl-overline
|
||||||
|
text-lg-subtitle-1
|
||||||
|
text-md-h5 font-weight-bold bg-black_and_white">
|
||||||
{{x.position__name}}
|
{{x.position__name}}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text
|
<v-card-text
|
||||||
@@ -60,7 +64,7 @@
|
|||||||
</v-switch>
|
</v-switch>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row >
|
<v-row class="ma-3">
|
||||||
<!-- <v-col class="fiction flex-column d-flex align-self-center"> -->
|
<!-- <v-col class="fiction flex-column d-flex align-self-center"> -->
|
||||||
<v-card-text class="d-flex flex-column align-self-center " v-if="changeData">
|
<v-card-text class="d-flex flex-column align-self-center " v-if="changeData">
|
||||||
<!-- <v-row> -->
|
<!-- <v-row> -->
|
||||||
@@ -92,8 +96,13 @@
|
|||||||
<!-- </v-row> -->
|
<!-- </v-row> -->
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-text v-else>
|
<v-card-text v-else>
|
||||||
|
<!-- class="text-h5 text-white text-center h-100 text-sm-overline" -->
|
||||||
<v-row class="text-h5 text-white text-center h-100" align-content="center">Данные не загружены </v-row>
|
<v-row
|
||||||
|
class="text-white text-center text-lg-h5 h-100 ma-3"
|
||||||
|
align-content="center"
|
||||||
|
>
|
||||||
|
Данные не загружены
|
||||||
|
</v-row>
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<!-- </v-col> -->
|
<!-- </v-col> -->
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ import AuthForm from '@/components/UI/Auth-form.vue'
|
|||||||
import OnlineUsers from '@/components/onlineUsers.vue'
|
import OnlineUsers from '@/components/onlineUsers.vue'
|
||||||
import CardUsers from '@/components/cardUsers.vue'
|
import CardUsers from '@/components/cardUsers.vue'
|
||||||
import CardLike from '@/components/cardLike.vue'
|
import CardLike from '@/components/cardLike.vue'
|
||||||
import { pagecounter } from '@/utils/universal_functions'
|
// import { pagecounter } from '@/utils/universal_functions'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { baseURL } from '@/utils/axios-api'
|
import { baseURL } from '@/utils/axios-api'
|
||||||
export default {
|
export default {
|
||||||
@@ -326,7 +326,7 @@ export default {
|
|||||||
mixins: [uf],
|
mixins: [uf],
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
pagecounter()
|
// pagecounter()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ const routes = [
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
component: () => import('@/layouts/default/DefaultPortal.vue'),
|
component: () => import('@/layouts/default/DefaultPortal.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Вход"
|
||||||
|
},
|
||||||
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
|
|||||||
@@ -66,17 +66,19 @@ export function pagecounter(){
|
|||||||
const accountStore = useAccountStore()
|
const accountStore = useAccountStore()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
console.log(router.currentRoute.value.meta, '----роутер страницы--');
|
console.log(router.currentRoute.value.meta, '----роутер страницы--');
|
||||||
let postdata = {user__id: "user" in accountStore &&"id" in accountStore.user? accountStore.user.id: null,
|
let postdata = {
|
||||||
page: router.currentRoute.value.meta.title,
|
user__id: "user" in accountStore &&"id" in accountStore.user? accountStore.user.id: null,
|
||||||
fullPath: router.currentRoute.value.fullPath,
|
page: router.currentRoute.value.meta.title,
|
||||||
ico: router.currentRoute.value.meta.ico
|
fullPath: router.currentRoute.value.fullPath,
|
||||||
|
ico: router.currentRoute.value.meta.ico
|
||||||
|
}
|
||||||
|
console.log(postdata, 'postdata');
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata)
|
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
|
||||||
appStore.countvisitor = result.data})
|
appStore.countvisitor = result.data})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -65,17 +65,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
|
||||||
import {getfromserver} from '@/utils/universal_functions'
|
import {getfromserver} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
setup(){
|
||||||
pagecounter()
|
|
||||||
const visiting = ref({})
|
const visiting = ref({})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getfromserver(`api/watcher/counter/`, visiting)
|
// getfromserver(`api/watcher/counter/`, visiting)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
visiting
|
visiting
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
setup(){
|
||||||
pagecounter()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container fluid class="d-flex mx-0 ">
|
<v-container fluid class="d-flex mx-0 pa-0">
|
||||||
<v-row>
|
<v-row class="ma-2">
|
||||||
<v-col
|
<v-col
|
||||||
class="d-flex flex-column"
|
class="d-flex flex-column"
|
||||||
lg=7
|
lg=7
|
||||||
md=12
|
md=12
|
||||||
cols=12
|
cols=12
|
||||||
>
|
>
|
||||||
<v-row class="flex-grow-0">
|
<v-row class="flex-grow-0">
|
||||||
<v-col class="pr-0 pb-0">
|
<v-col class="pa-1">
|
||||||
<Carousel-list/>
|
<Carousel-list/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row style="height:250px">
|
<v-row style="height:250px">
|
||||||
<v-col class="d-flex flex-column pr-0 pt-3" >
|
<v-col class="d-flex flex-column pa-1">
|
||||||
<event-calendar/>
|
<event-calendar/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -26,29 +26,27 @@
|
|||||||
>
|
>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row style="min-height:550px">
|
<v-row >
|
||||||
<v-col
|
<v-col
|
||||||
lg=4
|
lg=4
|
||||||
md=2
|
md=2
|
||||||
cols=12
|
cols=12
|
||||||
class="pb-0"
|
class="pa-1"
|
||||||
|
style="min-height:250px"
|
||||||
>
|
>
|
||||||
<digital-letna/>
|
<digital-letna/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col
|
<v-col
|
||||||
class="pb-0 pl-0 d-flex flex-column"
|
class="d-flex flex-column pa-1"
|
||||||
lg=8
|
lg=8
|
||||||
md=10
|
md=10
|
||||||
cols=12
|
cols=12
|
||||||
|
style="min-height:550px"
|
||||||
>
|
>
|
||||||
<v-card class="h-100 d-flex flex-column">
|
<v-card class="h-100 d-flex flex-column">
|
||||||
|
|
||||||
|
|
||||||
<v-row class="d-flex">
|
<v-row class="d-flex">
|
||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex">
|
||||||
<news-home/>
|
<news-home/>
|
||||||
<!-- <News-list-home /> -->
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -57,8 +55,8 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row class="flex-grow-0">
|
<v-row class="flex-grow-0">
|
||||||
<v-col>
|
<v-col class="pa-1">
|
||||||
<v-card class=" flex-colmn">
|
<v-card class="flex-colmn">
|
||||||
<v-btn-toggle
|
<v-btn-toggle
|
||||||
v-model="toggle"
|
v-model="toggle"
|
||||||
divided
|
divided
|
||||||
@@ -84,10 +82,6 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -129,8 +123,8 @@
|
|||||||
const favorit = ref([])
|
const favorit = ref([])
|
||||||
const toggle = ref(null)
|
const toggle = ref(null)
|
||||||
|
|
||||||
pagecounter()
|
|
||||||
const accountStore = useAccountStore()
|
const accountStore = useAccountStore()
|
||||||
|
pagecounter()
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
favoritLinks()
|
favoritLinks()
|
||||||
@@ -138,10 +132,11 @@
|
|||||||
|
|
||||||
const favoritLinks = () => {
|
const favoritLinks = () => {
|
||||||
|
|
||||||
axiosApiInstance.get(`api/watcher/selectedlinks/`)
|
|
||||||
.then(data => {
|
// axiosApiInstance.get(`api/watcher/selectedlinks/`)
|
||||||
favorit.value = data.data
|
// .then(data => {
|
||||||
})
|
// favorit.value = data.data
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
+20
-9
@@ -1,13 +1,11 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
from accounts.models import User
|
from accounts.models import User
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
class CountVisitor(models.Model):
|
class Pages(models.Model):
|
||||||
page = models.CharField(db_index=True, max_length=255)
|
page = models.CharField(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)
|
fullPath = models.CharField(max_length=255)
|
||||||
ico = models.CharField(verbose_name='Иконка', max_length=150, null=True, blank=True)
|
ico = models.CharField(verbose_name='Иконка', max_length=150, null=True, blank=True)
|
||||||
|
|
||||||
@@ -15,13 +13,26 @@ class CountVisitor(models.Model):
|
|||||||
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)
|
||||||
|
|
||||||
class Meta:
|
def __str__(self):
|
||||||
|
return str(self.pages)
|
||||||
|
|
||||||
|
|
||||||
constraints = [
|
|
||||||
models.UniqueConstraint(fields=['page', 'user', 'visitdate', 'fullPath', 'ico'], name='unique appversion')
|
# class Meta:
|
||||||
]
|
|
||||||
|
|
||||||
|
# constraints = [
|
||||||
|
# models.UniqueConstraint(fields=['page', 'user', 'visitdate', 'fullPath', 'ico'], name='unique appversion')
|
||||||
|
# ]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+1
-1
@@ -3,7 +3,7 @@ from .views import *
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('counter/', Counter.as_view(),name="CountVisitors"),
|
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
|
# path('', views.Watchuser.as_view()), selectedlinks
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+36
-25
@@ -16,49 +16,60 @@ class Counter(ListAPIView):
|
|||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
serializer_class = CountSerializer
|
serializer_class = CountSerializer
|
||||||
|
|
||||||
def get(self, request):
|
# def get(self, request):
|
||||||
res = CountVisitor.objects.values('page').annotate(Sum('count'))
|
# res = CountVisitor.objects.values('page').annotate(Sum('count'))
|
||||||
users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
|
# users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
|
||||||
outuser = DictEmployee.objects.values('login', 'fio')
|
# outuser = DictEmployee.objects.values('login', 'fio')
|
||||||
pUser = pd.DataFrame.from_records(users)
|
# pUser = pd.DataFrame.from_records(users)
|
||||||
pOutUser = pd.DataFrame.from_records(outuser)
|
# pOutUser = pd.DataFrame.from_records(outuser)
|
||||||
h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
|
# h = pUser.merge(pOutUser, how="left", left_on="user__username", right_on="login")
|
||||||
|
|
||||||
for x in users:
|
# for x in users:
|
||||||
if x['user__username'] is not None:
|
# if x['user__username'] is not None:
|
||||||
x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
|
# x['user__username'] = h.loc[h['login']==x['user__username']]['fio'].unique()[0]
|
||||||
else:
|
# else:
|
||||||
x['user__username'] = 'Анонимные'
|
# x['user__username'] = 'Анонимные'
|
||||||
|
|
||||||
return Response({"pages":res, "users": users})
|
# return Response({"pages":res, "users": users})
|
||||||
|
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
|
|
||||||
|
print('ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
myfullPath = request.data['fullPath']
|
myfullPath = request.data['fullPath']
|
||||||
if "?" in myfullPath:
|
if "?" in myfullPath:
|
||||||
myfullPath= myfullPath.split("?")[0]
|
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:
|
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'])
|
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),pages=page, visitdate=date.today())
|
||||||
|
print('if ----------------------------')
|
||||||
else:
|
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__id__isnull=True, pages=page, visitdate=date.today())
|
||||||
watch.count+=1
|
watch.count+=1
|
||||||
watch.save()
|
watch.save()
|
||||||
|
|
||||||
res = {"totalvisit": CountVisitor.objects.filter(page=request.data['page']).aggregate(Sum('count'))['count__sum'],
|
res = {"totalvisit": CountVisitor.objects.filter(pages=page.id).aggregate(Sum('count'))['count__sum'],
|
||||||
"visittoday":CountVisitor.objects.filter(visitdate=date.today(), page=request.data['page']).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(), page=request.data['page']).count()
|
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
class SelectedLinksAPIView(ListAPIView):
|
# class SelectedLinksAPIView(ListAPIView):
|
||||||
|
|
||||||
def get(self, request):
|
# def get(self, request):
|
||||||
user = User.objects.get(username=self.request.user)
|
# user = User.objects.get(username=self.request.user)
|
||||||
res = CountVisitor.objects.values('page','fullPath','ico').filter(user_id=user).annotate(Sum('count')).exclude(fullPath='/')
|
# res = CountVisitor.objects.values('page','fullPath','ico').filter(user_id=user).annotate(Sum('count')).exclude(fullPath='/')
|
||||||
sort = res.order_by('-count__sum')[:20]
|
# sort = res.order_by('-count__sum')[:20]
|
||||||
|
|
||||||
|
|
||||||
return Response(sort)
|
# return Response(sort)
|
||||||
|
|
||||||
Reference in new issue
Block a user