Посещаемость портала
Посчитать процент от прошлого периода
This commit is contained in:
1 parent
b00c186bfb
commit
bf06fa4363
2 files changed
+76
-69
No files matched your search
@@ -14,8 +14,10 @@
|
|||||||
<span class="font-weight-bold">
|
<span class="font-weight-bold">
|
||||||
{{selected_days.today}}
|
{{selected_days.today}}
|
||||||
</span>
|
</span>
|
||||||
: {{countvising['now'][0].size}}
|
: {{traffic.now.unique.size}}
|
||||||
/ {{countvising['now'][1]}}
|
/ {{traffic.now.percentage_staff}}
|
||||||
|
/ {{traffic.now.comparison_period.size}}
|
||||||
|
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
||||||
<v-list-item>
|
<v-list-item>
|
||||||
@@ -27,8 +29,9 @@
|
|||||||
<span class="font-weight-bold">
|
<span class="font-weight-bold">
|
||||||
{{selected_days.year[1]}}
|
{{selected_days.year[1]}}
|
||||||
</span>
|
</span>
|
||||||
: {{countvising['year'][0].size}}
|
{{traffic.year.unique.size}}
|
||||||
/ {{countvising['year'][1]}}
|
/ {{traffic.year.percentage_staff}}
|
||||||
|
/ {{traffic.year.comparison_period.size}}
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -44,13 +47,13 @@ export default {
|
|||||||
default: () => {}
|
default: () => {}
|
||||||
},
|
},
|
||||||
|
|
||||||
countvising: {
|
traffic: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {}
|
default: () => {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
console.log(props.countvising, 'Передача пропса');
|
console.log(props.traffic, 'Передача пропса');
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters class="ma-1">
|
<v-row no-gutters class="ma-1">
|
||||||
<v-col class="d-flex flex-column gap">
|
<v-col class="d-flex flex-column gap">
|
||||||
<my-helper :pretext="countvising"/>
|
<my-helper :pretext="traffic"/>
|
||||||
<v-row no-gutters class="flex-grow-0">
|
<v-row no-gutters class="flex-grow-0">
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-toolbar
|
<v-toolbar
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<v-col lg=3>
|
<v-col lg=3>
|
||||||
<portal-traffic
|
<portal-traffic
|
||||||
:selected_days=selected_days
|
:selected_days=selected_days
|
||||||
:countvising=countvising
|
:traffic=traffic
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
@@ -86,14 +86,14 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</thead>
|
</thead>
|
||||||
<!-- <tbody>
|
<tbody>
|
||||||
<tr v-for="(val, key) in countgrupp()" :key = key>
|
<tr v-for="(val, key) in pages_count" :key = key>
|
||||||
<td class="text-left">{{key}}</td>
|
<td class="text-left">{{key}}</td>
|
||||||
<td class="text-center">{{ modelrating?val.now[0].size:val.now[1] }} </td>
|
<td class="text-center">{{ modelrating?val.now.unique.size:val.now.countall }} </td>
|
||||||
<td class="text-center">{{ modelrating?val.year[0].size:val.year[1] }}</td>
|
<td class="text-center">{{ modelrating?val.year.unique.size:val.year.countall }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody> -->
|
</tbody>
|
||||||
</v-table>
|
</v-table>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -155,27 +155,33 @@ setup(){
|
|||||||
const visiting = ref([])
|
const visiting = ref([])
|
||||||
const feedback = ref([])
|
const feedback = ref([])
|
||||||
const staff = ref(0)
|
const staff = ref(0)
|
||||||
|
const pages_count = ref({})
|
||||||
const selected_days = ref({today: '', year: ''})
|
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 crit = ref([])
|
||||||
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
|
const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
|
||||||
const endate =ref(format2(new Date()))
|
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 icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline']
|
||||||
const modelrating = ref(false)
|
const modelrating = ref(false)
|
||||||
|
|
||||||
pagecounter()
|
pagecounter()
|
||||||
|
|
||||||
const weekstart = () => {
|
const weekstart = () => {
|
||||||
|
|
||||||
let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24))
|
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)))
|
previous_period.value = 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}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastperiod = () => {
|
const lastperiod = () => {
|
||||||
@@ -211,63 +217,60 @@ setup(){
|
|||||||
staff.value = result.data.staff
|
staff.value = result.data.staff
|
||||||
visiting.value = result.data.result
|
visiting.value = result.data.result
|
||||||
feedback.value = result.data.feedback
|
feedback.value = result.data.feedback
|
||||||
|
weekstart()
|
||||||
lastperiod()
|
lastperiod()
|
||||||
countgrupp()
|
countgrupp()
|
||||||
periodname()
|
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 groupedData =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const countgrupp = () => {
|
|
||||||
|
|
||||||
let us = {}
|
|
||||||
let countall = {now: [new Set(), 0, 0], year: [new Set(), 0]}
|
|
||||||
let lastday = new Set()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const groupedData =
|
|
||||||
visiting.value.reduce((acc, item) => {
|
visiting.value.reduce((acc, item) => {
|
||||||
|
|
||||||
|
|
||||||
if (!acc[item.pages]) {
|
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.unique.add(item.author.id)
|
||||||
acc[item.pages]['year'][1] += item.count
|
acc[item.pages].year.countall += item.count
|
||||||
countall['year'][0].add(item.author.id)
|
|
||||||
|
portal_traffic.year.unique.add(item.author.id)
|
||||||
|
|
||||||
if (item.visitdate == format2(endate.value)) {
|
if (item.visitdate == format2(endate.value)) {
|
||||||
acc[item.pages]['now'][0].add(item.author.id)
|
acc[item.pages].now.unique.add(item.author.id)
|
||||||
acc[item.pages]['now'][1] += item.count
|
acc[item.pages].now.countall += item.count
|
||||||
countall['now'][0].add(item.author.id)
|
|
||||||
|
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)){
|
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)) {
|
if (item.visitdate >= previous_period.value && item.visitdate <= format2(startdate.value)) {
|
||||||
// console.log(item.visitdate,' item.visitdate');
|
portal_traffic.year.comparison_period.add(item.author.id)
|
||||||
// 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
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -295,12 +298,12 @@ setup(){
|
|||||||
return acc
|
return acc
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
countall['now'][1] = percentageStaff(countall['now'][0])
|
portal_traffic.now.percentage_staff = percentageStaff(portal_traffic.now.unique)
|
||||||
countall['year'][1] = percentageStaff(countall['year'][0])
|
portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique)
|
||||||
|
console.log(portal_traffic, 'portal_traffic');
|
||||||
countvising.value = countall
|
pages_count.value = groupedData
|
||||||
|
traffic.value = portal_traffic
|
||||||
|
|
||||||
return groupedData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -358,7 +361,7 @@ setup(){
|
|||||||
activuser,
|
activuser,
|
||||||
|
|
||||||
feedback,
|
feedback,
|
||||||
countvising,
|
traffic,
|
||||||
crit,
|
crit,
|
||||||
visition,
|
visition,
|
||||||
returnstart,
|
returnstart,
|
||||||
@@ -369,7 +372,8 @@ setup(){
|
|||||||
periodname,
|
periodname,
|
||||||
weekstart,
|
weekstart,
|
||||||
selected_days,
|
selected_days,
|
||||||
modelrating
|
modelrating,
|
||||||
|
pages_count
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user