Сводная статистика посещений
This commit is contained in:
1 parent
8491195a5e
commit
6919ec314d
17 files changed
+162
-28
No files matched your search
BIN
Binary file not shown.
@@ -26,42 +26,65 @@ const routes = [
|
|||||||
path: '/providing',
|
path: '/providing',
|
||||||
name: 'ProvidingActivitiesPage',
|
name: 'ProvidingActivitiesPage',
|
||||||
component: () => import('@/views/ProvidingActivitiesPage.vue'),
|
component: () => import('@/views/ProvidingActivitiesPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Обеспечивающая деятельность"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/faq',
|
path: '/faq',
|
||||||
name: 'FAQPage',
|
name: 'FAQPage',
|
||||||
component: () => import('@/views/FAQPage.vue'),
|
component: () => import('@/views/FAQPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Часто задаваемые вопросы"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/feedback',
|
path: '/feedback',
|
||||||
name: 'FeedbackPage',
|
name: 'FeedbackPage',
|
||||||
component: () => import('@/views/FeedbackPage.vue'),
|
component: () => import('@/views/FeedbackPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Обратная связь"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/labor',
|
path: '/labor',
|
||||||
name: 'LaborProtection',
|
name: 'LaborProtection',
|
||||||
component: () => import('@/views/LaborProtection.vue'),
|
component: () => import('@/views/LaborProtection.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Безопасность"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/securyty',
|
path: '/securyty',
|
||||||
name: 'SecurityPage',
|
name: 'SecurityPage',
|
||||||
component: () => import('@/views/SecurityPage.vue'),
|
component: () => import('@/views/SecurityPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Охрана труда"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/inspection',
|
path: '/inspection',
|
||||||
name: 'AboutInspectionPage',
|
name: 'AboutInspectionPage',
|
||||||
component: () => import('@/views/AboutInspectionPage.vue'),
|
component: () => import('@/views/AboutInspectionPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Об инспекции"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/portal',
|
path: '/portal',
|
||||||
name: 'AboutPortalPage',
|
name: 'AboutPortalPage',
|
||||||
component: () => import('@/views/AboutPortalPage.vue'),
|
component: () => import('@/views/AboutPortalPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"О портале"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/news',
|
path: '/news',
|
||||||
name: 'AboutNewsPage',
|
name: 'AboutNewsPage',
|
||||||
component: () => import('@/views/NewsPage.vue'),
|
component: () => import('@/views/NewsPage.vue'),
|
||||||
|
meta:{
|
||||||
|
title:"Лента новостей"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,17 +38,12 @@ export function checkremote(filecheck){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default str;
|
export default str;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function pagecounter(){
|
export function pagecounter(){
|
||||||
console.log('Загружаю данные для циферок по количеству');
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const accountStore = useAccountStore()
|
const accountStore = useAccountStore()
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,55 @@
|
|||||||
<!-- </div> -->
|
<!-- </div> -->
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col
|
<v-col
|
||||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
class="ma-3"
|
||||||
>
|
>
|
||||||
О портале
|
{{visiting}}
|
||||||
|
<v-table density="compact">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-left">
|
||||||
|
Страница
|
||||||
|
</th>
|
||||||
|
<th class="text-left">
|
||||||
|
Количество посещений
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
|
v-for="item in visiting.pages"
|
||||||
|
:key="item.name"
|
||||||
|
>
|
||||||
|
<td>{{ item.page }}</td>
|
||||||
|
<td>{{ item.count__sum }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</v-table>
|
||||||
|
|
||||||
|
<v-table density="compact" class="mt-3">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-left">
|
||||||
|
Страница
|
||||||
|
</th>
|
||||||
|
<th class="text-left">
|
||||||
|
Количество посещений
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr
|
||||||
|
v-for="item in visiting.users"
|
||||||
|
:key="item.name"
|
||||||
|
>
|
||||||
|
<td>{{ item.user__username }}</td>
|
||||||
|
<td>{{ item.page }}</td>
|
||||||
|
<td>{{ item.count__sum }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</v-table>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
@@ -17,9 +62,29 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
|
import {getfromserver} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
const visiting = ref({})
|
||||||
|
|
||||||
|
const desserts = [
|
||||||
|
{
|
||||||
|
name: 'Frozen Yogurt',
|
||||||
|
calories: 159,
|
||||||
|
},]
|
||||||
|
|
||||||
|
getfromserver(`api/watcher/counter/`, visiting)
|
||||||
|
|
||||||
|
return {desserts,
|
||||||
|
visiting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import {useAppStore} from '@/store/app'
|
import {useAppStore} from '@/store/app'
|
||||||
import {useAccountStore} from '@/store/AccountStore'
|
import {useAccountStore} from '@/store/AccountStore'
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
|
|||||||
@@ -9,8 +9,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,15 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import NewsList from '@/components/news-list.vue'
|
import NewsList from '@/components/news-list.vue'
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
NewsList
|
NewsList
|
||||||
},
|
},
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -40,8 +40,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
setup(){
|
||||||
|
pagecounter()
|
||||||
const activates = [
|
const activates = [
|
||||||
{name: 'Комиссии', link: 'http://10.252.44.33/accounting6/SOTRYDNIKI.php#tab_committees'},
|
{name: 'Комиссии', link: 'http://10.252.44.33/accounting6/SOTRYDNIKI.php#tab_committees'},
|
||||||
{name: 'Ответственность', link: 'http://10.252.44.33/accounting6/SOTRYDNIKI.php#tab_departments'},
|
{name: 'Ответственность', link: 'http://10.252.44.33/accounting6/SOTRYDNIKI.php#tab_departments'},
|
||||||
|
|||||||
@@ -10,8 +10,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
setup(){
|
||||||
|
pagecounter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -17,3 +17,5 @@ class PlanCalendarAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
admin.site.register(GeneralVacation, GeneralVacationAdmin),
|
admin.site.register(GeneralVacation, GeneralVacationAdmin),
|
||||||
admin.site.register(PlanCalendar, PlanCalendarAdmin)
|
admin.site.register(PlanCalendar, PlanCalendarAdmin)
|
||||||
|
admin.site.register(BasePosition)
|
||||||
|
admin.site.register(DailyRoundUp)
|
||||||
@@ -41,7 +41,6 @@ class NewsAPIView(ListAPIView):
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
for x in newsqueryset:
|
for x in newsqueryset:
|
||||||
print(x.author, '--------------------------------------')
|
|
||||||
a=model_to_dict(x)
|
a=model_to_dict(x)
|
||||||
a['link']= str(x.link.url)
|
a['link']= str(x.link.url)
|
||||||
a['show'] = False
|
a['show'] = False
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from accounts.models import User
|
from accounts.models import User
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
class CountVisitor(models.Model):
|
class CountVisitor(models.Model):
|
||||||
page = models.CharField(db_index=True, max_length=255)
|
page = models.CharField(db_index=True, max_length=255)
|
||||||
visitdate = models.DateField()
|
visitdate = models.DateField()
|
||||||
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.PROTECT)
|
user = models.ForeignKey(User, null=True, blank=True, on_delete=models.PROTECT)
|
||||||
count = models.IntegerField(default=0)
|
count = models.IntegerField(default=0)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.page)
|
return str(self.page)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
constraints = [
|
constraints = [
|
||||||
@@ -15,3 +21,4 @@ class CountVisitor(models.Model):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+28
-11
@@ -1,3 +1,4 @@
|
|||||||
|
from django.forms import model_to_dict
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from rest_framework.generics import ListAPIView
|
from rest_framework.generics import ListAPIView
|
||||||
from .models import *
|
from .models import *
|
||||||
@@ -7,32 +8,48 @@ from django.views.generic import ListView
|
|||||||
from .serializers import *
|
from .serializers import *
|
||||||
from datetime import date
|
from datetime import date
|
||||||
from django.db.models import Sum
|
from django.db.models import Sum
|
||||||
|
from userauth.models import *
|
||||||
|
import pandas as pd
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
class Counter(ListAPIView):
|
class Counter(ListAPIView):
|
||||||
permission_classes = (AllowAny,)
|
permission_classes = (AllowAny,)
|
||||||
serializer_class = CountSerializer
|
serializer_class = CountSerializer
|
||||||
|
|
||||||
# def get(self, request):
|
def get(self, request):
|
||||||
# qs = CountVisitor.objects.values()
|
res = CountVisitor.objects.values('page').annotate(Sum('count'))
|
||||||
# return Response(qs)
|
users = CountVisitor.objects.values('page', 'user__username').annotate(Sum('count'))
|
||||||
|
outuser = DictEmployee.objects.using('user_directory').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")
|
||||||
|
# print(pUser, '!!!!!!!!!!!!!!!!!!!!!!!!')
|
||||||
|
# print(pOutUser, '???????????????????????')
|
||||||
|
print(h.loc[h['login']=='9966-00-125']['fio'].unique()[0], '11111111111111111111111111111')
|
||||||
|
# print(h.nunique(login='9966-00-125'))
|
||||||
|
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
# print(request.data['user__id'])
|
|
||||||
if request.data['user__id'] is not None:
|
if request.data['user__id'] is not None:
|
||||||
# print("sdddddd")
|
|
||||||
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),page=request.data['page'], visitdate=date.today())
|
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),page=request.data['page'], visitdate=date.today())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, page=request.data['page'], visitdate=date.today())
|
watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, page=request.data['page'], visitdate=date.today())
|
||||||
watch.count+=1
|
watch.count+=1
|
||||||
watch.save()
|
watch.save()
|
||||||
|
|
||||||
res = {"totalvisit": CountVisitor.objects.aggregate(Sum('count'))['count__sum'],
|
res = {"totalvisit": CountVisitor.objects.filter(page=request.data['page']).aggregate(Sum('count'))['count__sum'],
|
||||||
"visittoday":CountVisitor.objects.filter(visitdate=date.today()).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()).count()
|
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), page=request.data['page']).count()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(res)
|
return Response(res)
|
||||||
|
|
||||||
Reference in new issue
Block a user