Посещаемость портала

This commit is contained in:
iriska-gri committed 2024-03-04 13:29:30 +03:00
1 parent f5b7b1d10d
commit 83a505da5b
4 files changed
+92 -141

No files matched your search

@@ -1,6 +1,6 @@
<template>
<v-card class="text-center text-blue-grey-darken-4 d-flex h-100 flex-column cursor-default justify-center">
<!-- <my-helper :pretext="x"/> -->
<v-row no-gutters class="flex-grow-0 ">
<v-col class="text-h5 font-weight-bold pl-5">
{{indicator.title}}
@@ -4,23 +4,37 @@
:ico="'mdi-walk'"
>
<template v-slot:filling>
<v-table class="text-caption table_traffic ">
<v-table class="text-caption table_traffic pt-3">
<thead>
<tr>
<th class="pr-0"></th>
<th class="text-center px-1">сегодня</th>
<th class="text-center ">за период</th>
</tr>
<!-- <tr>
<th class="pr-0"></th>
<th class="text-center px-1">Уникальные пользователи</th>
<th class="text-center ">% от штата </th>
<th class="text-center pb-2">По сравнению предыдущим периодом</th>
</tr>
</tr> -->
</thead>
<tbody class="text-button">
<!-- -->
<tr
v-for="(val, key) in traffic"
:key = key
>
<td style="white-space: nowrap" class="text-left text-caption pr-0 pl-4 font-weight-medium cursor-default">{{val.title}}</td>
<td style="white-space: nowrap" class="text-left text-caption pr-0 pl-4 font-weight-medium cursor-default">
<!-- <my-helper :pretext="val"/> -->
<v-icon
size="large"
:color="val.color"
:icon="val.ico"
/>
</td>
<td class="text-center px-0 font-weight-bold text-h6 cursor-help text-grey-darken-3">
<v-tooltip location="top">
<v-tooltip location="top" v-if="val.proc!=''">
<template v-slot:activator="{ props }">
<span v-bind="props" >
{{ val.user.length }}
@@ -30,24 +44,28 @@
no-gutters v-for="n in val.user"
:key="n"
>
<v-col>
<v-col >
{{n}}
</v-col>
</v-row>
</v-tooltip>
</td>
<td class="text-center px-0 font-weight-bold text-h6 text-grey-darken-3 cursor-default">{{ val.proc }}%</td>
<td class="text-center font-weight-bold text-h6 text-grey-darken-3 cursor-default" v-if="val.previos">
<td class="text-center px-0 font-weight-bold text-h6 text-grey-darken-3 cursor-default" v-if="val.proc!=''">{{ val.proc }}%</td>
<td class="text-center font-weight-bold text-h6 text-grey-darken-3 cursor-default" v-else>
<v-icon
size="x-small"
:class="val.previos<val.user.length?'pb-1':'pt-0'"
:color="val.previos<val.user.length?'green-darken-2':'deep-orange-darken-4'"
:icon="val.previos<val.user.length?'mdi-arrow-up-bold':'mdi-arrow-down-bold'"
/>
<!-- -->
{{parseFloat((val.user.length * 100 /val.previos).toFixed(2))-100}} %
</td>
<td v-if="!val.previos"></td>
<!-- <td v-if="!val.previos"></td> -->
</tr>
</tbody>
</v-table>
@@ -85,15 +103,32 @@ export default {
get() {
let res = {
"today": {
"title": "сегодня",
"user": [],
"proc": ""
},
"period": {
"title": "за период",
"tooltip": "Уникальные пользователи",
"user": [],
"proc": "",
"previos": 0
"ico": "mdi-account-box",
"color" : "indigo"
},
"period": {
"tooltip": "% от штата",
"user": [],
"proc": "",
"ico": "mdi-chart-pie",
"color" : "green"
}
,
"before": {
"tooltip":"По сравнению предыдущим периодом",
"user": [],
"proc": "",
"previos": 0,
"ico": "mdi-elevation-rise",
"color" : "pink-darken-4"
}
}
@@ -108,7 +143,7 @@ export default {
}
})
res.before.user=res.period.user
res.today.proc = parseFloat(((res.today.user.length * 100) / props.alldata.staff).toFixed(2))
res.period.proc = parseFloat(((res.period.user.length * 100) / props.alldata.staff).toFixed(2))
@@ -118,9 +153,9 @@ export default {
props.alldata.beforperiod.filter( e=> data2.diff(moment(e.visitdate), 'days') < between).reduce((acc, item) => {
res.period.previos += item.user.length
res.before.previos += item.user.length
return acc
}, res.period.previos)
}, res.before.previos)
return res
}
+36 -13
View File
@@ -1,4 +1,36 @@
<template>
<v-row no-gutters class="gap ma-1 flex-column">
<v-col class="d-flex flex-column w100 pa-0 flex-grow-0">
<toolbar-filter/>
<!-- -->
</v-col>
<v-col class="bg-blue d-flex " >
<v-row no-gutters class="gap" >
<v-col lg=2 class=" d-flex flex-column">
<v-row no-gutters class="bg-red gap ma-0 flex-column">
<v-col lg=4 class="flex-column d-flex w100">
<portal-traffic :alldata=alldata />
</v-col>
<v-col class="flex-column d-flex w100">2</v-col>
</v-row>
</v-col>
<v-col class="bg-blue d-flex flex-column">
<v-row no-gutters class="flex-column gap">
<v-col lg=4 class="bg-yellow w100">
<line-chart
:key = "`${filterStore.date_period.startdate}-${filterStore.date_period.enddate}`"
:dataLineChart="dataLineChart"
:period="{before:alldata.beforperiod,period:alldata.period}"
:filter = filter
/>
</v-col>
</v-row>
</v-col>
<v-col lg=2 class="bg-red">3</v-col>
</v-row>
</v-col>
</v-row>
<!-- <v-row v-if="Object.keys(feedback).length==0">
<v-col class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light">
<v-progress-circular
@@ -10,8 +42,8 @@
</v-col>
</v-row> -->
<!-- v-else -->
<v-row no-gutters class="flex-column gap ma-1" >
<toolbar-filter/>
<!-- <v-row no-gutters class="flex-column gap ma-1" >
<v-col lg=4 class="w100">
<v-row no-gutters class="h-100 gap">
<v-col lg=2>
@@ -19,20 +51,11 @@
</v-col>
<v-col lg=8>
<line-chart
:key = "`${filterStore.date_period.startdate}-${filterStore.date_period.enddate}`"
:dataLineChart="dataLineChart"
:period="{before:alldata.beforperiod,period:alldata.period}"
:filter = filter
/>
</v-col>
</v-row>
</v-col>
<v-col class="w100 ">
<!-- -------------------------------------------------------------- -->
<!-- <my-helper :pretext="alldata.feedback"/> -->
<!-- -------------------------------------------------------------- -->
<v-row no-gutters class="h-100 gap">
<v-col class="flex-column d-flex">
<v-row no-gutters class="flex-column gap" >
@@ -60,7 +83,7 @@
</v-row>
</v-col>
</v-row>
</v-row> -->
</template>
+1 -108
View File
@@ -26,114 +26,7 @@ class Counter(ListAPIView):
return Response(data)
# data_start = datetime.strptime(request.GET.get("start"), "%Y-%m-%d").date() .aggregate(count = Count('user'))
# data_end = datetime.strptime(request.GET.get("end"), "%Y-%m-%d").date() .annotate(total=Count('user', distinct=True)).order_by('visitdate')
# beetween = datetime.strptime(request.GET.get("end"), "%Y-%m-%d").date() - (data_start + timedelta(days=1))
# crrdate = data_start - timedelta(days=1)
# new_date_start = data_start - beetween
# new_date_end = data_start - timedelta(days=1)
# # Посещаемость портала
# # res=CountVisitor.objects.all()
# res = CountVisitor.objects.filter(Q(visitdate__lte = request.GET.get("end")) | Q(visitdate=date.today()))
# visiting = res.filter(visitdate__gte=request.GET.get("start"))
# formulas = data_start
# indicators={}
# # print(formulas, 'formulasformulas')
# while (formulas <= data_end):
# indicators[formulas.strftime("%Y-%m-%d")] = {'crr': 0, 'br': 0, 'ppv': 0}
# # CRR
# all_end = res.filter(visitdate__lte = formulas).distinct()
# # Количество на начало периода
# crr_start = all_end.values('user', 'visitdate').filter(visitdate__lte = crrdate).count()
# # Количество клиентов на конец периода
# crr_end = all_end.values('user', 'visitdate').count()
# # Количество за выбранный период
# crr_per = crr_end - crr_start
# indicators[formulas.strftime("%Y-%m-%d")]['crr'] = ((crr_end - crr_per)/crr_start)*100
# # BR Количество сессий, в которых посетитель посмотрел не более 1 страницы
# br = res.filter(visitdate__range=[request.GET.get("start"), formulas]).values_list('user', 'visitdate').order_by('user', 'visitdate').annotate(count_pages=Count('pages')).filter(count_pages=1).count()
# # PPV
# ppv = res.filter(visitdate__range=[request.GET.get("start"), formulas]).count()
# if crr_per > 0:
# indicators[formulas.strftime("%Y-%m-%d")]['br'] = round((br/crr_per)*100, 2)
# indicators[formulas.strftime("%Y-%m-%d")]['ppv'] = round(ppv/crr_per, 2)
# formulas += timedelta(days=1)
# Обратная связь
# feed = UserComment.objects.all()
# rating = RatingStatus.objects.values('crit__name', 'crit__ico', 'crit__color', 'rating').filter(usercom__time_create__range=[request.GET.get("start"), request.GET.get("end")])
# d = feed.filter(time_create__range=[request.GET.get("start"), request.GET.get("end")])
# return Response({'result':CountSerializer(visiting, many=True).data,
# 'chart': indicators,
# 'feedback': {
# 'feed': UserCommentSerializer(d, many=True).data,
# 'criteria': list(rating.values('crit__name').annotate(ratings=Avg('rating'), name=F('crit__name'), ico=F('crit__ico'), color=F('crit__color')).values('ratings', 'name', 'ico', 'color')),
# 'data': {
# 'score': {
# 'title': 'Поставлено оценок',
# 'all': feed.count(),
# 'period': feed.filter(time_create__range=[request.GET.get("start"), request.GET.get("end")]).count()
# },
# 'comment': {
# 'title': 'Оставлено комментариев',
# 'all': feed.filter(~Q(comment='')).count(),
# 'period': feed.filter(Q(time_create__range=[request.GET.get("start"), request.GET.get("end")]) & ~Q(comment='')).count()
# }
# },
# 'last_comment': feed.values('time_create').filter(~Q(comment='')).latest('time_create'),
# },
# 'for_formulas': {
# 'staff': DictEmployee.objects.filter(deleted=0).count(),
# 'attendance': res.values_list('user', flat=True).filter(visitdate__range=[new_date_start, new_date_end]).distinct().count(),
# 'previos': res.values('user').filter(visitdate__range=[new_date_start, new_date_end]).distinct().count()
# },
# 'indicators': {
# 'crr': {
# 'title': "Удержание",
# 'abb': "(CRR)",
# 'tooltip': "Показатель удержания клиентов (retention rate) — это коэффициент, который отражает способность компании выстраивать крепкие отношения с покупателями. Он показывает, насколько хорошо бизнес удерживает постоянных клиентов в течение определенного промежутка времени. Метрику также называют customer retention rate, или CRR.",
# 'data': ((crr_end - crr_per)/crr_start)*100
# },
# 'br': {
# 'title': "Отказы",
# 'abb': "(BR)",
# 'tooltip': "Термин в веб-аналитике, обозначающий процентное соотношение количества посетителей, покинувших сайт прямо со страницы входа или просмотревших не более одной страницы сайта",
# 'data': (br/crr_per)*100,
# },
# 'ppv': {
# 'title': "Страниц за визит",
# 'abb': "(PPV)",
# 'tooltip': "Глубина просмотра страниц — поведенческая метрика, которая показывает, сколько страниц на сайте в среднем просматривает пользователь",
# 'data':ppv/crr_per
# }
# }
# })
def post(self, request):