Фильтр дат компонент
This commit is contained in:
1 parent
2478bb72ab
commit
61bd1cd362
5 files changed
+366
-229
No files matched your search
@@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<v-toolbar
|
||||||
|
density="compact"
|
||||||
|
class="text-h6 font-weight-regular"
|
||||||
|
>
|
||||||
|
<v-icon
|
||||||
|
icon="mdi-poll"
|
||||||
|
color="cyan-darken-3"
|
||||||
|
class="mx-2"
|
||||||
|
/>
|
||||||
|
Статистика портала за период с
|
||||||
|
<div class="px-2 pb-1">
|
||||||
|
<date-select
|
||||||
|
@returndate="returnstart"
|
||||||
|
:datedefault = "filterStore.date_period.startdate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
по
|
||||||
|
<div class="px-2 pb-1">
|
||||||
|
<date-select
|
||||||
|
@returndate="returnend"
|
||||||
|
:datedefault = "filterStore.date_period.enddate"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</v-toolbar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import DateSelect from '@/components/UI/date-select.vue'
|
||||||
|
import { usePortalFilterStore } from '@/store/AboutPortalFilter'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
DateSelect
|
||||||
|
},
|
||||||
|
|
||||||
|
setup(){
|
||||||
|
|
||||||
|
const filterStore = usePortalFilterStore()
|
||||||
|
|
||||||
|
const returnstart = (dates) => {
|
||||||
|
filterStore.date_period.startdate = dates
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnend = (dates) => {
|
||||||
|
filterStore.date_period.enddate = dates
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
returnstart,
|
||||||
|
returnend,
|
||||||
|
filterStore
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="selectedDate"
|
v-model="selectedDate"
|
||||||
:value="dateformat()"
|
:value="format1(datedefault)"
|
||||||
no-resize
|
no-resize
|
||||||
class="my-textarea"
|
class="my-textarea"
|
||||||
rows="1"
|
rows="1"
|
||||||
@@ -44,9 +44,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
|
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import {format1, format2} from '@/utils/universal_functions'
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
@@ -64,19 +64,17 @@ export default {
|
|||||||
const selectedDate = ref(null)
|
const selectedDate = ref(null)
|
||||||
|
|
||||||
const dateStart = () => {
|
const dateStart = () => {
|
||||||
emit('returndate', moment(selectedDate.value).format('YYYY-MM-DD'))
|
emit('returndate', selectedDate.value)
|
||||||
menudate.value=false
|
menudate.value=false
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateformat = () => {
|
|
||||||
return moment(props.datedefault).format('DD.MM.YYYY')
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
menudate,
|
menudate,
|
||||||
selectedDate,
|
selectedDate,
|
||||||
dateStart,
|
dateStart,
|
||||||
dateformat
|
format1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// Utilities
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
|
export const usePortalFilterStore = defineStore('filter', () => {
|
||||||
|
|
||||||
|
const date_period = ref({ "startdate": new Date(new Date().getFullYear(), 0, 1),
|
||||||
|
"enddate": new Date()
|
||||||
|
})
|
||||||
|
return { date_period }
|
||||||
|
},
|
||||||
|
)
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import {ref} from 'vue'
|
import {ref} from 'vue'
|
||||||
import { clearAxios } from '@/utils/axios-api'
|
import { clearAxios } from '@/utils/axios-api'
|
||||||
|
|
||||||
export const useMainmenuStore = defineStore('MainmenuStore', () => {
|
export const useMainmenuStore = defineStore('MainmenuStore', () => {
|
||||||
const portallinks = ref([])
|
const portallinks = ref([])
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters class="ma-1">
|
<v-row no-gutters class="flex-column">
|
||||||
<v-col class="d-flex flex-column gap">
|
<toolbar-filter
|
||||||
<my-helper :pretext="visiting"/>
|
@returnend="returnend"
|
||||||
|
/>
|
||||||
|
<v-col lg=1 class="w100 bg-red">
|
||||||
|
|
||||||
|
</v-col>
|
||||||
|
<v-col class="bg-green">2</v-col>
|
||||||
|
<!-- <v-col class="d-flex flex-column gap">
|
||||||
|
|
||||||
|
|
||||||
|
{{visitionreduce()}}
|
||||||
<v-row no-gutters class="flex-grow-0">
|
<v-row no-gutters class="flex-grow-0">
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-toolbar
|
<v-toolbar
|
||||||
@@ -25,12 +34,29 @@
|
|||||||
<div class="px-2 pb-1">
|
<div class="px-2 pb-1">
|
||||||
<date-select
|
<date-select
|
||||||
@returndate="returnend"
|
@returndate="returnend"
|
||||||
:datedefault = "endate"
|
:datedefault = "enddate"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<v-row>
|
||||||
|
|
||||||
|
</v-row>
|
||||||
|
<v-row class="flex-grow-0">
|
||||||
|
<v-col lg=3>
|
||||||
|
|
||||||
|
visiting- (все данные)
|
||||||
|
</v-col>
|
||||||
|
<v-col > <my-helper :pretext="visiting"/> </v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-row class="flex-grow-0">
|
||||||
|
<v-col lg=3>
|
||||||
|
|
||||||
|
dataLineChart (данные для графика)-
|
||||||
|
</v-col>
|
||||||
|
<v-col> <my-helper :pretext="dataLineChart"/> </v-col>
|
||||||
|
</v-row> -->
|
||||||
|
|
||||||
<!-- <v-row no-gutters class="gap flex-grow-0">
|
<!-- <v-row no-gutters class="gap flex-grow-0">
|
||||||
<v-col lg=3>
|
<v-col lg=3>
|
||||||
@@ -122,7 +148,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
</v-col>
|
<!-- </v-col> -->
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@@ -139,6 +165,7 @@ import DateSelect from '@/components/UI/date-select.vue'
|
|||||||
import TopUser from '@/components/UI/aboutportal/top-user.vue'
|
import TopUser from '@/components/UI/aboutportal/top-user.vue'
|
||||||
import LineChart from '@/components/UI/aboutportal/line-chart.vue'
|
import LineChart from '@/components/UI/aboutportal/line-chart.vue'
|
||||||
import PortalTraffic from '@/components/UI/aboutportal/portal-traffic.vue'
|
import PortalTraffic from '@/components/UI/aboutportal/portal-traffic.vue'
|
||||||
|
import ToolbarFilter from '@/components/UI/aboutportal/toolbar-filter.vue'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -147,7 +174,8 @@ export default {
|
|||||||
DateSelect,
|
DateSelect,
|
||||||
TopUser,
|
TopUser,
|
||||||
LineChart,
|
LineChart,
|
||||||
PortalTraffic
|
PortalTraffic,
|
||||||
|
ToolbarFilter
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@@ -155,56 +183,20 @@ 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 traffic = ref({
|
|
||||||
now: {
|
|
||||||
title: '',
|
|
||||||
unique: new Set(),
|
|
||||||
percentage_staff: 0,
|
|
||||||
comparison_period: new Set(),
|
|
||||||
percentage_period: 0
|
|
||||||
},
|
|
||||||
year: {
|
|
||||||
title: '',
|
|
||||||
unique: new Set(),
|
|
||||||
percentage_staff: 0,
|
|
||||||
comparison_period: new Set(),
|
|
||||||
percentage_period: 0
|
|
||||||
}
|
|
||||||
})
|
|
||||||
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 enddate =ref(format2(new Date()))
|
||||||
const last_days = ref(new Date())
|
const dataLineChart = ref({})
|
||||||
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()
|
pagecounter()
|
||||||
|
|
||||||
const weekstart = () => {
|
const visition = () => {
|
||||||
|
axiosApiInstance.get(`api/watcher/counter/`).then(result => {
|
||||||
|
staff.value = result.data.staff
|
||||||
|
visiting.value = result.data.result
|
||||||
|
feedback.value = result.data.feedback
|
||||||
|
})}
|
||||||
|
|
||||||
// console.log( , '!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
visition()
|
||||||
let days_between = Math.floor((new Date(endate.value) - new Date(startdate.value)) / (1000*60*60*24))
|
|
||||||
if (startdate.value == endate.value) {
|
|
||||||
days_between = 1
|
|
||||||
}
|
|
||||||
previous_period.value = new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastperiod = () => {
|
|
||||||
let last_day = []
|
|
||||||
visiting.value.map((e)=>{
|
|
||||||
|
|
||||||
if (e.visitdate < format2(endate.value)) {
|
|
||||||
last_day.push(e.visitdate)
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
last_days.value = last_day[last_day.length-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
const returnstart = (dates) => {
|
const returnstart = (dates) => {
|
||||||
startdate.value = dates
|
startdate.value = dates
|
||||||
@@ -212,202 +204,275 @@ setup(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const returnend = (dates) => {
|
const returnend = (dates) => {
|
||||||
endate.value = dates
|
enddate.value = dates
|
||||||
visition()
|
visition()
|
||||||
}
|
}
|
||||||
|
|
||||||
const periodname = () => {
|
const visitionreduce = () => {
|
||||||
selected_days.value.today = 'сегодня'
|
let lineCharts = {}
|
||||||
if (format2(new Date()) != format2(endate.value)) {
|
const groupedData = visiting.value.reduce((acc, item) => {
|
||||||
selected_days.value.today = format1(endate.value)
|
|
||||||
|
// Данные для графика по фильтру
|
||||||
|
if (item.visitdate >= format2(startdate.value) && item.visitdate <= format2(enddate.value)){
|
||||||
|
|
||||||
|
if (!lineCharts[item.visitdate]) {
|
||||||
|
lineCharts[item.visitdate] = {count: 0, unic: new Set()}
|
||||||
}
|
}
|
||||||
selected_days.value.year = [format1(startdate.value), format1(endate.value)]
|
lineCharts[item.visitdate]['count'] +=item.count
|
||||||
}
|
lineCharts[item.visitdate]['unic'].add(splitname(item.author))
|
||||||
|
|
||||||
const visition = () => {
|
|
||||||
let start = startdate.value
|
|
||||||
if (startdate.value == endate.value) {
|
|
||||||
start = format2(new Date(startdate.value).setDate(new Date(startdate.value).getDate() -1))
|
|
||||||
}
|
|
||||||
axiosApiInstance.get(`api/watcher/counter/?start=${start}&end=${endate.value}`).then(result => {
|
|
||||||
staff.value = result.data.staff
|
|
||||||
visiting.value = result.data.result
|
|
||||||
feedback.value = result.data.feedback
|
|
||||||
weekstart()
|
|
||||||
lastperiod()
|
|
||||||
periodname()
|
|
||||||
countgrupp()
|
|
||||||
})}
|
|
||||||
|
|
||||||
const countgrupp = () => {
|
|
||||||
let us = {}
|
|
||||||
let portal_traffic = {
|
|
||||||
now: {
|
|
||||||
title: '',
|
|
||||||
info: '',
|
|
||||||
unique: new Set(),
|
|
||||||
percentage_staff: 0,
|
|
||||||
comparison_period: new Set(),
|
|
||||||
percentage_period: 0
|
|
||||||
},
|
|
||||||
year: {
|
|
||||||
title: 'За период',
|
|
||||||
info: '',
|
|
||||||
unique: new Set(),
|
|
||||||
percentage_staff: 0,
|
|
||||||
comparison_period: new Set(),
|
|
||||||
percentage_period: 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const groupedData =
|
|
||||||
visiting.value.reduce((acc, item) => {
|
|
||||||
|
|
||||||
if (!acc[item.pages]) {
|
|
||||||
acc[item.pages] = {
|
|
||||||
now:
|
|
||||||
{unique: new Set(), countall: 0},
|
|
||||||
year:
|
|
||||||
{unique: new Set(), countall: 0}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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.unique.add(item.author.id)
|
|
||||||
acc[item.pages].now.countall += item.count
|
|
||||||
|
|
||||||
portal_traffic.now.unique.add(item.author.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Посещаемость портала для периода 1 день
|
|
||||||
if (item.visitdate ==format2(last_days.value)){
|
|
||||||
portal_traffic.now.comparison_period.add(item.author.id)
|
|
||||||
portal_traffic.now.info = `за ${format1(last_days.value)}`
|
|
||||||
}
|
|
||||||
portal_traffic.year.info = `с ${format1(previous_period.value)} по ${format1(startdate.value)} `
|
|
||||||
console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} <= ${format1(startdate.value)}`,'до')
|
|
||||||
|
|
||||||
|
|
||||||
// Посещаемость портала для периода - выбранный период фильтра
|
|
||||||
if (item.visitdate >= format2(previous_period.value) && item.visitdate < format2(startdate.value)) {
|
|
||||||
console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} < ${format1(startdate.value)}`,'после')
|
|
||||||
console.log(previous_period.value, format2(startdate.value), '-------------------------------')
|
|
||||||
portal_traffic.year.comparison_period.add(item.author.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!us[splitname(item.author)])
|
|
||||||
{
|
|
||||||
us[splitname(item.author)] = {page: new Set(), login: 0}
|
|
||||||
}
|
|
||||||
|
|
||||||
us[splitname(item.author)]['page'].add(item.pages)
|
|
||||||
us[splitname(item.author)]['login'] = item.author.login
|
|
||||||
|
|
||||||
|
|
||||||
let arrcount = []
|
|
||||||
for (let [key,val] of Object.entries(us)) {
|
|
||||||
|
|
||||||
arrcount.push({fio:key,max:val.page.size, login: val.login})
|
|
||||||
}
|
|
||||||
arrcount.sort((a, b) => {
|
|
||||||
|
|
||||||
return b['max']- a['max']
|
|
||||||
})
|
|
||||||
|
|
||||||
crit.value = arrcount.slice(0, 3)
|
|
||||||
|
|
||||||
return acc
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
portal_traffic.now.percentage_staff = percentageStaff(portal_traffic.now.unique, staff.value)
|
|
||||||
portal_traffic.now.percentage_period = percentageStaff(portal_traffic.now.comparison_period, portal_traffic.now.unique.size)
|
|
||||||
portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique, staff.value)
|
|
||||||
portal_traffic.year.percentage_period = percentageStaff(portal_traffic.year.comparison_period, portal_traffic.year.unique.size)
|
|
||||||
portal_traffic.now.title = `На ${selected_days.value.today}`
|
|
||||||
|
|
||||||
pages_count.value = groupedData
|
|
||||||
traffic.value = portal_traffic
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
dataLineChart.value = lineCharts
|
||||||
|
|
||||||
|
|
||||||
const percentageStaff = (customers, delitel) => {
|
|
||||||
return Math.round((customers.size*100)/delitel)+'%'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const activuser = () => {
|
|
||||||
|
|
||||||
const groupedData =
|
|
||||||
visiting.value.reduce((acc, item) => {
|
|
||||||
|
|
||||||
if (!acc[splitname(item.author)]) {
|
|
||||||
acc[splitname(item.author)] = {count: 0, login: '', fio: '', post: '', info: new Set()}
|
|
||||||
}
|
|
||||||
|
|
||||||
acc[splitname(item.author)]['fio'] = splitname(item.author)
|
|
||||||
acc[splitname(item.author)]['info'].add(item.pages)
|
|
||||||
acc[splitname(item.author)]['login'] = item.author.login
|
|
||||||
acc[splitname(item.author)]['post'] = item.author.post
|
|
||||||
acc[splitname(item.author)]['count'] += item.count
|
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
|
|
||||||
const sorted = Object.entries(groupedData)
|
|
||||||
.sort(([,a],[,b]) => (b.count - a.count))
|
|
||||||
.reduce((r, [k, v]) =>
|
|
||||||
({ ...r, [k]: v } ), {}
|
|
||||||
|
|
||||||
)
|
return groupedData
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return sorted
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visition()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
visiting,
|
visiting,
|
||||||
countgrupp,
|
enddate,
|
||||||
activuser,
|
startdate,
|
||||||
|
|
||||||
feedback,
|
|
||||||
traffic,
|
|
||||||
crit,
|
|
||||||
visition,
|
|
||||||
returnstart,
|
returnstart,
|
||||||
returnend,
|
returnend,
|
||||||
endate,
|
visitionreduce,
|
||||||
startdate,
|
dataLineChart
|
||||||
icons,
|
// countgrupp,
|
||||||
periodname,
|
// activuser,
|
||||||
weekstart,
|
|
||||||
selected_days,
|
// feedback,
|
||||||
modelrating,
|
// traffic,
|
||||||
pages_count
|
// crit,
|
||||||
|
// visition,
|
||||||
|
|
||||||
|
|
||||||
|
// icons,
|
||||||
|
// periodname,
|
||||||
|
// weekstart,
|
||||||
|
// selected_days,
|
||||||
|
// modelrating,
|
||||||
|
// pages_count
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// const pages_count = ref({})
|
||||||
|
// const selected_days = ref({today: '', year: ''})
|
||||||
|
// const traffic = ref({
|
||||||
|
// now: {
|
||||||
|
// title: '',
|
||||||
|
// unique: new Set(),
|
||||||
|
// percentage_staff: 0,
|
||||||
|
// comparison_period: new Set(),
|
||||||
|
// percentage_period: 0
|
||||||
|
// },
|
||||||
|
// year: {
|
||||||
|
// title: '',
|
||||||
|
// unique: new Set(),
|
||||||
|
// percentage_staff: 0,
|
||||||
|
// comparison_period: new Set(),
|
||||||
|
// percentage_period: 0
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// const crit = 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const weekstart = () => {
|
||||||
|
|
||||||
|
|
||||||
|
// let days_between = Math.floor((new Date(enddate.value) - new Date(startdate.value)) / (1000*60*60*24))
|
||||||
|
// if (startdate.value == enddate.value) {
|
||||||
|
// days_between = 1
|
||||||
|
// }
|
||||||
|
// previous_period.value = new Date(new Date(startdate.value).setDate(new Date(startdate.value).getDate() - days_between))
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const lastperiod = () => {
|
||||||
|
// let last_day = []
|
||||||
|
// visiting.value.map((e)=>{
|
||||||
|
|
||||||
|
// if (e.visitdate < format2(enddate.value)) {
|
||||||
|
// last_day.push(e.visitdate)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// })
|
||||||
|
// last_days.value = last_day[last_day.length-1]
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const periodname = () => {
|
||||||
|
// selected_days.value.today = 'сегодня'
|
||||||
|
// if (format2(new Date()) != format2(enddate.value)) {
|
||||||
|
// selected_days.value.today = format1(enddate.value)
|
||||||
|
// }
|
||||||
|
// selected_days.value.year = [format1(startdate.value), format1(enddate.value)]
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const countgrupp = () => {
|
||||||
|
// let us = {}
|
||||||
|
// let portal_traffic = {
|
||||||
|
// now: {
|
||||||
|
// title: '',
|
||||||
|
// info: '',
|
||||||
|
// unique: new Set(),
|
||||||
|
// percentage_staff: 0,
|
||||||
|
// comparison_period: new Set(),
|
||||||
|
// percentage_period: 0
|
||||||
|
// },
|
||||||
|
// year: {
|
||||||
|
// title: 'За период',
|
||||||
|
// info: '',
|
||||||
|
// unique: new Set(),
|
||||||
|
// percentage_staff: 0,
|
||||||
|
// comparison_period: new Set(),
|
||||||
|
// percentage_period: 0
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const groupedData =
|
||||||
|
// visiting.value.reduce((acc, item) => {
|
||||||
|
|
||||||
|
// if (!acc[item.pages]) {
|
||||||
|
// acc[item.pages] = {
|
||||||
|
// now:
|
||||||
|
// {unique: new Set(), countall: 0},
|
||||||
|
// year:
|
||||||
|
// {unique: new Set(), countall: 0}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 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(enddate.value)) {
|
||||||
|
// acc[item.pages].now.unique.add(item.author.id)
|
||||||
|
// acc[item.pages].now.countall += item.count
|
||||||
|
|
||||||
|
// portal_traffic.now.unique.add(item.author.id)
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Посещаемость портала для периода 1 день
|
||||||
|
// if (item.visitdate ==format2(last_days.value)){
|
||||||
|
// portal_traffic.now.comparison_period.add(item.author.id)
|
||||||
|
// portal_traffic.now.info = `за ${format1(last_days.value)}`
|
||||||
|
// }
|
||||||
|
// portal_traffic.year.info = `с ${format1(previous_period.value)} по ${format1(startdate.value)} `
|
||||||
|
// console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} <= ${format1(startdate.value)}`,'до')
|
||||||
|
|
||||||
|
|
||||||
|
// Посещаемость портала для периода - выбранный период фильтра
|
||||||
|
// if (item.visitdate >= format2(previous_period.value) && item.visitdate < format2(startdate.value)) {
|
||||||
|
// console.log( `${format1(previous_period.value)} >=${format1(item.visitdate)} < ${format1(startdate.value)}`,'после')
|
||||||
|
// console.log(previous_period.value, format2(startdate.value), '-------------------------------')
|
||||||
|
// portal_traffic.year.comparison_period.add(item.author.id)
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// if (!us[splitname(item.author)])
|
||||||
|
// {
|
||||||
|
// us[splitname(item.author)] = {page: new Set(), login: 0}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// us[splitname(item.author)]['page'].add(item.pages)
|
||||||
|
// us[splitname(item.author)]['login'] = item.author.login
|
||||||
|
|
||||||
|
|
||||||
|
// let arrcount = []
|
||||||
|
// for (let [key,val] of Object.entries(us)) {
|
||||||
|
|
||||||
|
// arrcount.push({fio:key,max:val.page.size, login: val.login})
|
||||||
|
// }
|
||||||
|
// arrcount.sort((a, b) => {
|
||||||
|
|
||||||
|
// return b['max']- a['max']
|
||||||
|
// })
|
||||||
|
|
||||||
|
// crit.value = arrcount.slice(0, 3)
|
||||||
|
|
||||||
|
// return acc
|
||||||
|
// }, {});
|
||||||
|
|
||||||
|
// portal_traffic.now.percentage_staff = percentageStaff(portal_traffic.now.unique, staff.value)
|
||||||
|
// portal_traffic.now.percentage_period = percentageStaff(portal_traffic.now.comparison_period, portal_traffic.now.unique.size)
|
||||||
|
// portal_traffic.year.percentage_staff = percentageStaff(portal_traffic.year.unique, staff.value)
|
||||||
|
// portal_traffic.year.percentage_period = percentageStaff(portal_traffic.year.comparison_period, portal_traffic.year.unique.size)
|
||||||
|
// portal_traffic.now.title = `На ${selected_days.value.today}`
|
||||||
|
|
||||||
|
// pages_count.value = groupedData
|
||||||
|
// traffic.value = portal_traffic
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const percentageStaff = (customers, delitel) => {
|
||||||
|
// return Math.round((customers.size*100)/delitel)+'%'
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// const activuser = () => {
|
||||||
|
|
||||||
|
// const groupedData =
|
||||||
|
// visiting.value.reduce((acc, item) => {
|
||||||
|
|
||||||
|
// if (!acc[splitname(item.author)]) {
|
||||||
|
// acc[splitname(item.author)] = {count: 0, login: '', fio: '', post: '', info: new Set()}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// acc[splitname(item.author)]['fio'] = splitname(item.author)
|
||||||
|
// acc[splitname(item.author)]['info'].add(item.pages)
|
||||||
|
// acc[splitname(item.author)]['login'] = item.author.login
|
||||||
|
// acc[splitname(item.author)]['post'] = item.author.post
|
||||||
|
// acc[splitname(item.author)]['count'] += item.count
|
||||||
|
|
||||||
|
// return acc
|
||||||
|
// }, {})
|
||||||
|
|
||||||
|
|
||||||
|
// const sorted = Object.entries(groupedData)
|
||||||
|
// .sort(([,a],[,b]) => (b.count - a.count))
|
||||||
|
// .reduce((r, [k, v]) =>
|
||||||
|
// ({ ...r, [k]: v } ), {}
|
||||||
|
|
||||||
|
// )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// return sorted
|
||||||
|
// }
|
||||||
|
|
||||||
|
// visition()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user