Посещаемость портала
Посчитать процент от прошлого периода
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">
|
||||
{{selected_days.today}}
|
||||
</span>
|
||||
: {{countvising['now'][0].size}}
|
||||
/ {{countvising['now'][1]}}
|
||||
: {{traffic.now.unique.size}}
|
||||
/ {{traffic.now.percentage_staff}}
|
||||
/ {{traffic.now.comparison_period.size}}
|
||||
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item>
|
||||
@@ -27,8 +29,9 @@
|
||||
<span class="font-weight-bold">
|
||||
{{selected_days.year[1]}}
|
||||
</span>
|
||||
: {{countvising['year'][0].size}}
|
||||
/ {{countvising['year'][1]}}
|
||||
{{traffic.year.unique.size}}
|
||||
/ {{traffic.year.percentage_staff}}
|
||||
/ {{traffic.year.comparison_period.size}}
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
@@ -44,13 +47,13 @@ export default {
|
||||
default: () => {}
|
||||
},
|
||||
|
||||
countvising: {
|
||||
traffic: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
console.log(props.countvising, 'Передача пропса');
|
||||
console.log(props.traffic, 'Передача пропса');
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<v-row no-gutters class="ma-1">
|
||||
<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-col>
|
||||
<v-toolbar
|
||||
@@ -36,7 +36,7 @@
|
||||
<v-col lg=3>
|
||||
<portal-traffic
|
||||
:selected_days=selected_days
|
||||
:countvising=countvising
|
||||
:traffic=traffic
|
||||
/>
|
||||
</v-col>
|
||||
<v-col>
|
||||
@@ -86,14 +86,14 @@
|
||||
</tr>
|
||||
|
||||
</thead>
|
||||
<!-- <tbody>
|
||||
<tr v-for="(val, key) in countgrupp()" :key = key>
|
||||
<tbody>
|
||||
<tr v-for="(val, key) in pages_count" :key = key>
|
||||
<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.year[0].size:val.year[1] }}</td>
|
||||
<td class="text-center">{{ modelrating?val.now.unique.size:val.now.countall }} </td>
|
||||
<td class="text-center">{{ modelrating?val.year.unique.size:val.year.countall }}</td>
|
||||
</tr>
|
||||
|
||||
</tbody> -->
|
||||
</tbody>
|
||||
</v-table>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -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
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user