Отрисовка параметров

This commit is contained in:
iriska-gri committed 2024-02-14 13:56:05 +03:00
1 parent 92b3461f05
commit 7c331fdb72
3 files changed
+48 -41

No files matched your search

@@ -1,51 +1,47 @@
<template>
<v-card
class="text-center d-flex h-100 flex-column"
>
<v-tooltip width="250">
<template v-slot:activator="{ props }">
<v-icon
icon="mdi-information"
color="cyan-darken-3"
size="12"
v-bind="props"
class="align-self-end pr-2 pt-2"
/>
</template>
<span class="text-caption" >
{{indicator.tooltip}}
</span>
</v-tooltip>
<v-row no-gutters class="flex-grow-0 ">
<v-col class="text-h5 ">
{{indicator.title}}
</v-col>
</v-row>
<v-row no-gutters class="flex-grow-0">
<v-col class="text-h5 font-weight-bold">
{{indicator.abb}}
</v-col>
</v-row>
<v-row no-gutters class="">
<v-col class="text-h2 text-center font-weight-medium align-self-center">
{{indicator.data}}
</v-col>
</v-row>
<v-card class="text-center d-flex h-100 flex-column">
<v-tooltip width="250">
<template v-slot:activator="{ props }">
<v-icon
icon="mdi-information"
color="cyan-darken-3"
size="12"
v-bind="props"
class="align-self-end pr-2 pt-2"
/>
</template>
<span class="text-caption" >
{{indicator.tooltip}}
</span>
</v-tooltip>
<v-row no-gutters class="flex-grow-0 ">
<v-col class="text-h5 ">
{{indicator.title}}
</v-col>
</v-row>
<v-row no-gutters class="flex-grow-0">
<v-col class="text-h5 font-weight-bold">
{{indicator.abb}}
</v-col>
</v-row>
<v-row no-gutters>
<v-col class="text-h2 text-center font-weight-medium align-self-center">
{{indicator.data}}
</v-col>
</v-row>
</v-card>
</template>
<script>
export default {
props: {
indicator: {
type: Object,
default: {}
},
}
}
</script>
@@ -18,7 +18,7 @@
<tr >
<th></th>
<th class="text-center">Уникальные пользователи</th>
<th class="text-center">% от шага</th>
<th class="text-center">% от штата</th>
<th class="text-center">По сравнению предыдущим периодом</th>
</tr>
+15 -4
View File
@@ -18,8 +18,15 @@ class Counter(ListAPIView):
permission_classes = (AllowAny,)
serializer_class = CountSerializer
def get(self, request):
def get(self, request):
def is_integer(x):
return x % 1 ==0
def toFixed(numObj, digits=0):
return f"{numObj:.{digits}f}"
perioddata = CountVisitor.objects.filter(visitdate__range=[request.GET.get("start"), request.GET.get("end")])
data_start = datetime.strptime(request.GET.get("start"), "%Y-%m-%d").date()
@@ -38,6 +45,7 @@ class Counter(ListAPIView):
crr_start = CountVisitor.objects.values('user', 'visitdate').filter(visitdate__lte = crrdate).distinct().count()
crr_end = CountVisitor.objects.values('user', 'visitdate').filter(visitdate__lte = request.GET.get("end")).distinct().count()
crr_per = crr_end - crr_start
crr = ((crr_end - crr_per)/crr_start)*100
# BR
br = perioddata.values_list('user', 'visitdate').order_by('user', 'visitdate').annotate(count_pages=Count('pages')).filter(count_pages=1).count()
@@ -80,25 +88,28 @@ class Counter(ListAPIView):
'title': "Удержание",
'abb': "(CRR)",
'tooltip': "Показатель удержания клиентов (retention rate) — это коэффициент, который отражает способность компании выстраивать крепкие отношения с покупателями. Он показывает, насколько хорошо бизнес удерживает постоянных клиентов в течение определенного промежутка времени. Метрику также называют customer retention rate, или CRR.",
'data':round(((crr_end - crr_per)/crr_start)*100, 2),
'data': f"{toFixed(crr)}%" if is_integer(crr) == True else f"{round(crr, 2)}%",
},
'br': {
'title': "Отказы",
'abb': "(BR)",
'tooltip': "Термин в веб-аналитике, обозначающий процентное соотношение количества посетителей, покинувших сайт прямо со страницы входа или просмотревших не более одной страницы сайта",
'data': round((br/crr_per)*100, 2),
'data': f"{toFixed((br/crr_per)*100)}%" if is_integer((br/crr_per)*100) == True else f"{round((br/crr_per)*100, 2)}%",
},
'ppv': {
'title': "Страниц за визит",
'abb': "(PPV)",
'tooltip': "Глубина просмотра страниц — поведенческая метрика, которая показывает, сколько страниц на сайте в среднем просматривает пользователь",
'data':round(ppv/crr_per, 2)
'data':round(ppv/crr_per, 0)
}
}
})
def post(self, request):