From 7c331fdb72902afb2da08393a934a595055c198b Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Wed, 14 Feb 2024 13:56:05 +0300
Subject: [PATCH] =?UTF-8?q?=D0=9E=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?=
=?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80?=
=?UTF-8?q?=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/UI/aboutportal/card-total.vue | 68 +++++++++----------
.../UI/aboutportal/portal-traffic.vue | 2 +-
src/watcher/views.py | 19 ++++--
3 files changed, 48 insertions(+), 41 deletions(-)
diff --git a/src/front/src/components/UI/aboutportal/card-total.vue b/src/front/src/components/UI/aboutportal/card-total.vue
index f1819884e..7c5b781db 100644
--- a/src/front/src/components/UI/aboutportal/card-total.vue
+++ b/src/front/src/components/UI/aboutportal/card-total.vue
@@ -1,51 +1,47 @@
-
-
-
-
-
-
- {{indicator.tooltip}}
-
-
-
-
- {{indicator.title}}
-
-
-
-
- {{indicator.abb}}
-
-
-
-
-
- {{indicator.data}}
-
-
-
+
+
+
+
+
+
+ {{indicator.tooltip}}
+
+
+
+
+ {{indicator.title}}
+
+
+
+
+ {{indicator.abb}}
+
+
+
+
+ {{indicator.data}}
+
+
diff --git a/src/front/src/components/UI/aboutportal/portal-traffic.vue b/src/front/src/components/UI/aboutportal/portal-traffic.vue
index ada9293e9..d31eb8105 100644
--- a/src/front/src/components/UI/aboutportal/portal-traffic.vue
+++ b/src/front/src/components/UI/aboutportal/portal-traffic.vue
@@ -18,7 +18,7 @@
|
Уникальные пользователи |
- % от шага |
+ % от штата |
По сравнению предыдущим периодом |
diff --git a/src/watcher/views.py b/src/watcher/views.py
index 5b8ae4756..ef45307a6 100644
--- a/src/watcher/views.py
+++ b/src/watcher/views.py
@@ -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):