Сводная статистика посещений
This commit is contained in:
1 parent
8491195a5e
commit
6919ec314d
17 files changed
+164
-30
No files matched your search
BIN
Binary file not shown.
@@ -26,42 +26,65 @@ const routes = [
|
||||
path: '/providing',
|
||||
name: 'ProvidingActivitiesPage',
|
||||
component: () => import('@/views/ProvidingActivitiesPage.vue'),
|
||||
meta:{
|
||||
title:"Обеспечивающая деятельность"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/faq',
|
||||
name: 'FAQPage',
|
||||
component: () => import('@/views/FAQPage.vue'),
|
||||
|
||||
meta:{
|
||||
title:"Часто задаваемые вопросы"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/feedback',
|
||||
name: 'FeedbackPage',
|
||||
component: () => import('@/views/FeedbackPage.vue'),
|
||||
meta:{
|
||||
title:"Обратная связь"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/labor',
|
||||
name: 'LaborProtection',
|
||||
component: () => import('@/views/LaborProtection.vue'),
|
||||
meta:{
|
||||
title:"Безопасность"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/securyty',
|
||||
name: 'SecurityPage',
|
||||
component: () => import('@/views/SecurityPage.vue'),
|
||||
meta:{
|
||||
title:"Охрана труда"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/inspection',
|
||||
name: 'AboutInspectionPage',
|
||||
component: () => import('@/views/AboutInspectionPage.vue'),
|
||||
meta:{
|
||||
title:"Об инспекции"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/portal',
|
||||
name: 'AboutPortalPage',
|
||||
component: () => import('@/views/AboutPortalPage.vue'),
|
||||
meta:{
|
||||
title:"О портале"
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/news',
|
||||
name: 'AboutNewsPage',
|
||||
component: () => import('@/views/NewsPage.vue'),
|
||||
meta:{
|
||||
title:"Лента новостей"
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -38,17 +38,12 @@ export function checkremote(filecheck){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export default str;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function pagecounter(){
|
||||
console.log('Загружаю данные для циферок по количеству');
|
||||
|
||||
const router = useRouter()
|
||||
const accountStore = useAccountStore()
|
||||
const appStore = useAppStore()
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -5,10 +5,55 @@
|
||||
<!-- </div> -->
|
||||
<v-row>
|
||||
<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>
|
||||
|
||||
@@ -17,9 +62,29 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
import {getfromserver} from '@/utils/universal_functions'
|
||||
export default {
|
||||
setup(){
|
||||
pagecounter()
|
||||
const visiting = ref({})
|
||||
|
||||
const desserts = [
|
||||
{
|
||||
name: 'Frozen Yogurt',
|
||||
calories: 159,
|
||||
},]
|
||||
|
||||
getfromserver(`api/watcher/counter/`, visiting)
|
||||
|
||||
return {desserts,
|
||||
visiting
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, computed } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import {useAppStore} from '@/store/app'
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
|
||||
@@ -9,8 +9,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -13,10 +13,15 @@
|
||||
|
||||
<script>
|
||||
import NewsList from '@/components/news-list.vue'
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
NewsList
|
||||
},
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -40,8 +40,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
|
||||
export default {
|
||||
setup(){
|
||||
pagecounter()
|
||||
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_departments'},
|
||||
|
||||
@@ -10,8 +10,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
export default {
|
||||
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -16,4 +16,6 @@ class PlanCalendarAdmin(admin.ModelAdmin):
|
||||
fields = ('name', 'start_work_period', 'end_work_period')
|
||||
|
||||
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 = []
|
||||
|
||||
for x in newsqueryset:
|
||||
print(x.author, '--------------------------------------')
|
||||
a=model_to_dict(x)
|
||||
a['link']= str(x.link.url)
|
||||
a['show'] = False
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
from django.db import models
|
||||
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)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.page)
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['page', 'user', 'visitdate'], name='unique appversion')
|
||||
]
|
||||
|
||||
|
||||
|
||||
+28
-11
@@ -1,3 +1,4 @@
|
||||
from django.forms import model_to_dict
|
||||
from django.shortcuts import render
|
||||
from rest_framework.generics import ListAPIView
|
||||
from .models import *
|
||||
@@ -7,32 +8,48 @@ from django.views.generic import ListView
|
||||
from .serializers import *
|
||||
from datetime import date
|
||||
from django.db.models import Sum
|
||||
|
||||
from userauth.models import *
|
||||
import pandas as pd
|
||||
# Create your views here.
|
||||
|
||||
class Counter(ListAPIView):
|
||||
permission_classes = (AllowAny,)
|
||||
serializer_class = CountSerializer
|
||||
|
||||
# def get(self, request):
|
||||
# qs = CountVisitor.objects.values()
|
||||
# return Response(qs)
|
||||
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.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):
|
||||
# print(request.data['user__id'])
|
||||
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())
|
||||
|
||||
else:
|
||||
watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, page=request.data['page'], visitdate=date.today())
|
||||
watch.count+=1
|
||||
watch.save()
|
||||
|
||||
res = {"totalvisit": CountVisitor.objects.aggregate(Sum('count'))['count__sum'],
|
||||
"visittoday":CountVisitor.objects.filter(visitdate=date.today()).aggregate(Sum('count'))['count__sum'],
|
||||
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today()).count()
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
return Response(res)
|
||||
|
||||
Reference in new issue
Block a user