From bf06fa43635e4f54c9cd2f7519247852559d9041 Mon Sep 17 00:00:00 2001
From: iriska-gri <79623434+iriska-gri@users.noreply.github.com>
Date: Mon, 29 Jan 2024 16:59:41 +0300
Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=81=D0=B5=D1=89=D0=B0=D0=B5?=
=?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D1=8C=20=D0=BF=D0=BE=D1=80=D1=82=D0=B0?=
=?UTF-8?q?=D0=BB=D0=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Посчитать процент от прошлого периода
---
.../UI/aboutportal/portal-traffic.vue | 15 +-
src/front/src/views/AboutPortalPage.vue | 130 +++++++++---------
2 files changed, 76 insertions(+), 69 deletions(-)
diff --git a/src/front/src/components/UI/aboutportal/portal-traffic.vue b/src/front/src/components/UI/aboutportal/portal-traffic.vue
index fd96d8cc7..fd49c9748 100644
--- a/src/front/src/components/UI/aboutportal/portal-traffic.vue
+++ b/src/front/src/components/UI/aboutportal/portal-traffic.vue
@@ -14,8 +14,10 @@
{{selected_days.today}}
- : {{countvising['now'][0].size}}
- / {{countvising['now'][1]}}
+ : {{traffic.now.unique.size}}
+ / {{traffic.now.percentage_staff}}
+ / {{traffic.now.comparison_period.size}}
+
@@ -27,8 +29,9 @@
{{selected_days.year[1]}}
- : {{countvising['year'][0].size}}
- / {{countvising['year'][1]}}
+ {{traffic.year.unique.size}}
+ / {{traffic.year.percentage_staff}}
+ / {{traffic.year.comparison_period.size}}
@@ -44,13 +47,13 @@ export default {
default: () => {}
},
- countvising: {
+ traffic: {
type: Object,
default: () => {}
}
},
setup(props) {
- console.log(props.countvising, 'Передача пропса');
+ console.log(props.traffic, 'Передача пропса');
return {}
}
diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue
index 02cd4bd0c..71d0982b7 100644
--- a/src/front/src/views/AboutPortalPage.vue
+++ b/src/front/src/views/AboutPortalPage.vue
@@ -1,7 +1,7 @@
-
+
@@ -86,14 +86,14 @@
-
+
@@ -155,27 +155,33 @@ setup(){
const visiting = ref([])
const feedback = ref([])
const staff = ref(0)
+ const pages_count = ref({})
const selected_days = ref({today: '', year: ''})
- const countvising = ref({now: [new Set(), 0], period: [new Set(), 0], year: [new Set(), 0]})
+ const traffic = ref({
+ now: {
+ unique: new Set(),
+ percentage_staff: 0,
+ comparison_period: new Set()
+ },
+ year: {
+ unique: new Set(),
+ percentage_staff: 0,
+ comparison_period: new Set()
+ }
+ })
const crit = ref([])
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
const endate =ref(format2(new Date()))
- const last_days = ref('')
+ const last_days = ref(new Date())
+ const previous_period = ref(new Date())
const icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline']
const modelrating = ref(false)
pagecounter()
const weekstart = () => {
-
let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24))
- let start = format1(new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between)))
- let end = ''
-
- console.log(start, end, days_between, format1(last_days.value), 'относительно сегодня');
- // let Start = moment(date).subtract(1, 'weeks').startOf('isoWeek')._d // начало предыдущей недели
- // let End =new Date(new Date(WeekStart).setDate(new Date(WeekStart).getDate() + 4)) // конец предыдущей недели
- return {start, end}
+ previous_period.value = format1(new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between)))
}
const lastperiod = () => {
@@ -211,63 +217,60 @@ setup(){
staff.value = result.data.staff
visiting.value = result.data.result
feedback.value = result.data.feedback
+ weekstart()
lastperiod()
countgrupp()
periodname()
- weekstart()
})}
-
+ const countgrupp = () => {
+ let us = {}
+ let portal_traffic = {
+ now: {
+ unique: new Set(),
+ percentage_staff: 0,
+ comparison_period: new Set()
+ },
+ year: {
+ unique: new Set(),
+ percentage_staff: 0,
+ comparison_period: new Set()
+ }
+ }
-
-
-
-
- const countgrupp = () => {
-
- let us = {}
- let countall = {now: [new Set(), 0, 0], year: [new Set(), 0]}
- let lastday = new Set()
-
-
-
- const groupedData =
+ const groupedData =
visiting.value.reduce((acc, item) => {
-
if (!acc[item.pages]) {
- acc[item.pages] = {now: [new Set(), 0], year: [new Set(), 0]}
+ acc[item.pages] = {
+ now:
+ {unique: new Set(), countall: 0},
+ year:
+ {unique: new Set(), countall: 0}
+ }
}
- acc[item.pages]['year'][0].add(item.author.id)
- acc[item.pages]['year'][1] += item.count
- countall['year'][0].add(item.author.id)
+ acc[item.pages].year.unique.add(item.author.id)
+ acc[item.pages].year.countall += item.count
+
+ portal_traffic.year.unique.add(item.author.id)
if (item.visitdate == format2(endate.value)) {
- acc[item.pages]['now'][0].add(item.author.id)
- acc[item.pages]['now'][1] += item.count
- countall['now'][0].add(item.author.id)
+ acc[item.pages].now.unique.add(item.author.id)
+ acc[item.pages].now.countall += item.count
+
+ portal_traffic.now.unique.add(item.author.id)
}
- console.log(format1(last_days.value), 'last_days.value');
-
- // Посещаемость портала для перода 1 день
+ // Посещаемость портала для периода 1 день
if (item.visitdate ==format2(last_days.value)){
- lastday.add(item.author.id)
-
+ portal_traffic.now.comparison_period.add(item.author.id)
}
- countall['now'][2] = lastday.size
- // console.log(lastday, 'format2(last_day[last_day.length-1])')
- // console.log(item.visitdate, , 'item.visitdate');
- // let week = weekstart(endate.value)
- // if (item.visitdate >=format2(week.start) && item.visitdate <= format2(week.end)) {
- // console.log(item.visitdate,' item.visitdate');
- // acc[item.pages]['week'][0].add(item.author.id)
- // acc[item.pages]['week'][1] += item.count
- // countall['week'][0].add(item.author.id)
- // countall['week'][1] += item.count
- // }
+ // Посещаемость портала для периода - выбранный период фильтра
+ if (item.visitdate >= previous_period.value && item.visitdate <= format2(startdate.value)) {
+ portal_traffic.year.comparison_period.add(item.author.id)
+ }
@@ -295,12 +298,12 @@ setup(){
return acc
}, {});
- countall['now'][1] = percentageStaff(countall['now'][0])
- countall['year'][1] = percentageStaff(countall['year'][0])
-
- countvising.value = countall
+ portal_traffic.now.percentage_staff = percentageStaff(portal_traffic.now.unique)
+ portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique)
+ console.log(portal_traffic, 'portal_traffic');
+ pages_count.value = groupedData
+ traffic.value = portal_traffic
- return groupedData
}
@@ -358,7 +361,7 @@ setup(){
activuser,
feedback,
- countvising,
+ traffic,
crit,
visition,
returnstart,
@@ -369,7 +372,8 @@ setup(){
periodname,
weekstart,
selected_days,
- modelrating
+ modelrating,
+ pages_count
}