1
This commit is contained in:
1 parent
a68fa255e4
commit
5aa4136cfd
9 files changed
+984
-506
No files matched your search
@@ -20,10 +20,7 @@ export default {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
},
|
||||
dataChart: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
setup(props, {emit}) {
|
||||
@@ -42,7 +39,7 @@ export default {
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: [],
|
||||
hidden: true,
|
||||
|
||||
tooltips: false
|
||||
|
||||
},
|
||||
@@ -65,7 +62,7 @@ export default {
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: [],
|
||||
|
||||
hidden: true,
|
||||
customlabel: [],
|
||||
tooltips: true
|
||||
}
|
||||
@@ -77,7 +74,7 @@ export default {
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: [],
|
||||
|
||||
hidden: true,
|
||||
customlabel: [],
|
||||
tooltips: true
|
||||
}
|
||||
@@ -89,7 +86,7 @@ export default {
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: [],
|
||||
|
||||
hidden: true,
|
||||
customlabel: [],
|
||||
tooltips: true
|
||||
}
|
||||
@@ -151,19 +148,9 @@ export default {
|
||||
}
|
||||
|
||||
const arrforline=() => {
|
||||
let dataYear = {}
|
||||
|
||||
|
||||
Object.entries(props.dataLineChart).forEach(e => {
|
||||
|
||||
const [key, value] = e
|
||||
console.log(value,' e');
|
||||
let year = dataYear[new Date(key).getFullYear()]
|
||||
if (!dataYear[year]) {
|
||||
dataYear[year] = {count: 0}}
|
||||
dataYear[year].count += value.count
|
||||
|
||||
|
||||
|
||||
arrlines.value.datasets[0].data.push(value.count)
|
||||
arrlines.value.datasets[1].data.push(value.unic.length)
|
||||
arrlines.value.datasets[2].data.push(value.crr)
|
||||
@@ -173,7 +160,7 @@ export default {
|
||||
arrlines.value.datasets[1].customlabel.push(props.dataLineChart[key].unic)
|
||||
})
|
||||
|
||||
console.log(dataYear);
|
||||
console.log(props.dataLineChart,'dataYear2 -------------');
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<tr>
|
||||
<th class="pr-0"></th>
|
||||
<th class="text-center px-1">Уникальные пользователи</th>
|
||||
<th class="text-center ">% от штата</th>
|
||||
<th class="text-center ">% от штата </th>
|
||||
<th class="text-center pb-2">По сравнению предыдущим периодом</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -36,15 +36,16 @@
|
||||
</v-row>
|
||||
</v-tooltip>
|
||||
</td>
|
||||
<td class="text-center px-0 font-weight-bold text-h6 text-grey-darken-3 cursor-default">{{ val.proc }}</td>
|
||||
<td class="text-center px-0 font-weight-bold text-h6 text-grey-darken-3 cursor-default">{{ val.proc }}%</td>
|
||||
<td class="text-center font-weight-bold text-h6 text-grey-darken-3 cursor-default" v-if="val.previos">
|
||||
<v-icon
|
||||
size="x-small"
|
||||
:class="val.previos>0?'pb-1':'pt-0'"
|
||||
:color="val.previos>0?'green-darken-2':'deep-orange-darken-4'"
|
||||
:icon="val.previos>0?'mdi-arrow-up-bold':'mdi-arrow-down-bold'"
|
||||
:class="val.previos<val.user.length?'pb-1':'pt-0'"
|
||||
:color="val.previos<val.user.length?'green-darken-2':'deep-orange-darken-4'"
|
||||
:icon="val.previos<val.user.length?'mdi-arrow-up-bold':'mdi-arrow-down-bold'"
|
||||
/>
|
||||
{{ val.previos }}%
|
||||
<!-- <my-helper :pretext="alldata.beforperiod"/> -->
|
||||
{{100 - parseFloat( val.user.length * 100 /val.previos).toFixed(2)}} %
|
||||
</td>
|
||||
<td v-if="!val.previos"></td>
|
||||
</tr>
|
||||
@@ -56,6 +57,10 @@
|
||||
|
||||
<script>
|
||||
import PatternCard from '@/components/UI/aboutportal/pattern-card.vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import {formatDash, splitname, checking_for_entry} from '@/utils/universal_functions'
|
||||
import { usePortalFilterStore } from '@/store/AboutPortalFilter'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
|
||||
components: {
|
||||
@@ -64,15 +69,73 @@ export default {
|
||||
|
||||
props: {
|
||||
|
||||
traffic: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
}
|
||||
alldata: {
|
||||
type: Object,
|
||||
default: () => {return {period: [], staff: 0}}
|
||||
},
|
||||
|
||||
// traffic: {
|
||||
// type: Object,
|
||||
// default: () => {}
|
||||
// }
|
||||
},
|
||||
setup(props) {
|
||||
console.log(props.traffic, 'Передача пропса');
|
||||
const filterStore = usePortalFilterStore()
|
||||
const traffic = computed({
|
||||
get() {
|
||||
let res = {
|
||||
"today": {
|
||||
"title": "сегодня",
|
||||
"user": [],
|
||||
"proc": ""
|
||||
},
|
||||
"period": {
|
||||
"title": "за период",
|
||||
"user": [],
|
||||
"proc": "",
|
||||
"previos": 0
|
||||
}
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
props.alldata.period.forEach(e => {
|
||||
if (e.visitdate == formatDash(new Date())) {
|
||||
checking_for_entry(res.today.user, splitname(e.user))
|
||||
}
|
||||
if (new Date(e.visitdate) <= filterStore.date_period.enddate) {
|
||||
checking_for_entry(res.period.user, splitname(e.user))
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
res.today.proc = parseFloat(((res.today.user.length * 100) / props.alldata.staff).toFixed(2))
|
||||
res.period.proc = parseFloat(((res.period.user.length * 100) / props.alldata.staff).toFixed(2))
|
||||
|
||||
let data1 = moment(filterStore.date_period.enddate)
|
||||
let data2 = moment(filterStore.date_period.startdate)
|
||||
let between = data1.diff(data2, 'days') + 1
|
||||
|
||||
|
||||
props.alldata.beforperiod.filter( e=> data2.diff(moment(e.visitdate), 'days') < between).reduce((acc, item) => {
|
||||
res.period.previos += item.total
|
||||
return acc
|
||||
}, res.period.previos)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.log( data1.diff(data2, 'days'), 'props.alldata')
|
||||
return res
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return {
|
||||
traffic
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@ export function formaComaTime(date) {
|
||||
return moment(date).format('DD.MM.YYYY H:mm')
|
||||
}
|
||||
|
||||
export function checking_for_entry (where, what) {
|
||||
if (!where.includes(what))
|
||||
{
|
||||
where.push(what)
|
||||
}
|
||||
}
|
||||
|
||||
export function getfromserver(path, reactive){
|
||||
try{
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-row v-if="Object.keys(feedback).length==0">
|
||||
<!-- <v-row v-if="Object.keys(feedback).length==0">
|
||||
<v-col class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light">
|
||||
<v-progress-circular
|
||||
:size="150"
|
||||
@@ -8,22 +8,25 @@
|
||||
indeterminate
|
||||
></v-progress-circular>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="flex-column gap ma-1" v-else>
|
||||
</v-row> -->
|
||||
<!-- v-else -->
|
||||
<v-row no-gutters class="flex-column gap ma-1" >
|
||||
<toolbar-filter/>
|
||||
<v-col lg=3 class="w100">
|
||||
<v-row no-gutters class="h-100 gap">
|
||||
<v-col >
|
||||
<portal-traffic :traffic=dataAttendance />
|
||||
<portal-traffic :alldata=alldata />
|
||||
</v-col>
|
||||
<v-col lg=9>
|
||||
|
||||
<line-chart :dataLineChart="dataLineChart" :dataChart="dataChart"/>
|
||||
<!-- <line-chart :dataLineChart="dataLineChart" :dataChart="dataChart"/> -->
|
||||
</v-col>
|
||||
<v-col>
|
||||
<v-btn>1</v-btn>
|
||||
<v-btn>2</v-btn>
|
||||
<v-btn>3</v-btn>
|
||||
<v-col >
|
||||
<v-btn block class="text-caption" @click="filter='year'">Год</v-btn>
|
||||
<v-btn block class="text-caption" @click="filter='month'">Месяц</v-btn>
|
||||
<v-btn block class="text-caption" @click="filter='day'">День</v-btn>
|
||||
|
||||
{{filter}}
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
@@ -32,27 +35,27 @@
|
||||
<v-row no-gutters class="h-100 gap">
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class="flex-column gap" >
|
||||
<v-col v-for="x in dataIndicators" :key=x>
|
||||
<!-- <v-col v-for="x in dataIndicators" :key=x>
|
||||
<card-total :indicator=x />
|
||||
</v-col>
|
||||
</v-col> -->
|
||||
</v-row>
|
||||
|
||||
</v-col>
|
||||
<v-col lg=4 class="d-flex flex-column">
|
||||
<rating-page :pages_count=pages_count />
|
||||
<!-- <rating-page :pages_count=pages_count /> -->
|
||||
</v-col>
|
||||
<v-col lg=4 class="d-flex flex-column ">
|
||||
|
||||
<top-user
|
||||
<!-- <top-user
|
||||
:activusers = dataActivusers
|
||||
|
||||
/>
|
||||
/> -->
|
||||
|
||||
</v-col>
|
||||
<v-col lg=2 class="d-flex flex-column">
|
||||
<feedmodul
|
||||
<!-- <feedmodul
|
||||
:feedback="feedback"
|
||||
/>
|
||||
/> -->
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
@@ -96,492 +99,297 @@ export default {
|
||||
|
||||
|
||||
setup(){
|
||||
|
||||
const filterStore = usePortalFilterStore()
|
||||
const alldata =ref({period: [], staff: 0, beforperiod: []})
|
||||
const visition = () => {
|
||||
|
||||
const visiting = ref([])
|
||||
const feedback = ref([])
|
||||
const for_formulas = ref({})
|
||||
|
||||
const dataLineChart = ref({})
|
||||
const dataActivusers = ref([])
|
||||
const dataAttendance = ref({})
|
||||
const dataIndicators = ref({})
|
||||
const dataChart = ref({})
|
||||
|
||||
const unicuser = ref([])
|
||||
|
||||
const selected_days = ref({today: 'сегодня', year: {start: new Date(), end: new Date()}})
|
||||
const pages_count = ref({data: {}, title: {}})
|
||||
|
||||
|
||||
pagecounter()
|
||||
|
||||
const visition = () => {
|
||||
|
||||
axiosApiInstance.get(`api/watcher/counter/?start=${formatDash(filterStore.date_period.startdate)}&end=${formatDash(filterStore.date_period.enddate)}`).then(result => {
|
||||
for_formulas.value = result.data.for_formulas
|
||||
visiting.value = result.data.result
|
||||
feedback.value = result.data.feedback
|
||||
dataIndicators.value = result.data.indicators
|
||||
dataChart.value = result.data.chart,
|
||||
axiosApiInstance.get(`api/watcher/testwatcher/?start=${formatDash(filterStore.date_period.startdate)}&end=${formatDash(filterStore.date_period.enddate)}`).then(result => {
|
||||
alldata.value = result.data
|
||||
console.log(result.data, 'result.data');
|
||||
|
||||
visitionreduce()
|
||||
funActiveUser()
|
||||
|
||||
|
||||
})}
|
||||
|
||||
visition()
|
||||
|
||||
const checking_for_entry = (where, what) => {
|
||||
if (!where.includes(what))
|
||||
{
|
||||
where.push(what)
|
||||
}
|
||||
}
|
||||
watch(()=>filterStore.date_period,()=>{
|
||||
|
||||
visition()
|
||||
|
||||
|
||||
}, {deep:true})
|
||||
// const filter = ref('day')
|
||||
// const visiting = ref([])
|
||||
// const feedback = ref([])
|
||||
// const for_formulas = ref({})
|
||||
|
||||
// const dataLineChart = ref({})
|
||||
// const dataActivusers = ref([])
|
||||
// const dataAttendance = ref({})
|
||||
// const dataIndicators = ref({})
|
||||
// const dataChart = ref({})
|
||||
|
||||
// const unicuser = ref([])
|
||||
|
||||
// const selected_days = ref({today: 'сегодня', year: {start: new Date(), end: new Date()}})
|
||||
// const pages_count = ref({data: {}, title: {}})
|
||||
|
||||
|
||||
// pagecounter()
|
||||
|
||||
// const visition = () => {
|
||||
|
||||
// axiosApiInstance.get(`api/watcher/counter/?start=${formatDash(filterStore.date_period.startdate)}&end=${formatDash(filterStore.date_period.enddate)}`).then(result => {
|
||||
// for_formulas.value = result.data.for_formulas
|
||||
// visiting.value = result.data.result
|
||||
// feedback.value = result.data.feedback
|
||||
// dataIndicators.value = result.data.indicators
|
||||
// dataChart.value = result.data.chart,
|
||||
// console.log(result.data, 'result.data');
|
||||
|
||||
// visitionreduce()
|
||||
// funActiveUser()
|
||||
|
||||
// })}
|
||||
|
||||
// visition()
|
||||
|
||||
// const checking_for_entry = (where, what) => {
|
||||
// if (!where.includes(what))
|
||||
// {
|
||||
// where.push(what)
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
const funLineChart = (data, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
if (!data[item.visitdate]) {
|
||||
data[item.visitdate] = {count: 0, unic: []}
|
||||
}
|
||||
checking_for_entry(data[item.visitdate]['unic'], splitname(item.author))
|
||||
data[item.visitdate].count += item.count
|
||||
}
|
||||
}
|
||||
// const funLineChart = (data, item) => {
|
||||
// if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
// if (!data[item.visitdate]) {
|
||||
// data[item.visitdate] = {count: 0, unic: []}
|
||||
// }
|
||||
// checking_for_entry(data[item.visitdate]['unic'], splitname(item.author))
|
||||
// data[item.visitdate].count += item.count
|
||||
// }
|
||||
// }
|
||||
|
||||
const funActiveUser = () => {
|
||||
dataActivusers.value = []
|
||||
unicuser.value.map(iduser => {
|
||||
// const funActiveUser = () => {
|
||||
// dataActivusers.value = []
|
||||
// unicuser.value.map(iduser => {
|
||||
|
||||
let activuser ={
|
||||
user: {
|
||||
id: "",
|
||||
login: "",
|
||||
post: "",
|
||||
fio: ""
|
||||
},
|
||||
info: {
|
||||
count: 0,
|
||||
session: 0,
|
||||
pages: 0
|
||||
},
|
||||
tooltip: [],
|
||||
}
|
||||
// let activuser ={
|
||||
// user: {
|
||||
// id: "",
|
||||
// login: "",
|
||||
// post: "",
|
||||
// fio: ""
|
||||
// },
|
||||
// info: {
|
||||
// count: 0,
|
||||
// session: 0,
|
||||
// pages: 0
|
||||
// },
|
||||
// tooltip: [],
|
||||
// }
|
||||
|
||||
let yearpages = {}
|
||||
let pages = []
|
||||
let user = visiting.value.filter(e => e.author.id == iduser)
|
||||
// let yearpages = {}
|
||||
// let pages = []
|
||||
// let user = visiting.value.filter(e => e.author.id == iduser)
|
||||
|
||||
const groupUser = user.reduce((acc, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
funyearpages(yearpages, item)
|
||||
checking_for_entry(pages, item.pages)
|
||||
acc['id'] = item.author.id
|
||||
acc['login'] = item.author.login
|
||||
acc['post'] = item.author.post
|
||||
acc['fio'] = splitname(item.author)
|
||||
acc['count'] += item.count
|
||||
acc['session'] = Object.keys(yearpages).length
|
||||
}
|
||||
return acc
|
||||
}, {count: 0})
|
||||
// const groupUser = user.reduce((acc, item) => {
|
||||
// if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
// funyearpages(yearpages, item)
|
||||
// checking_for_entry(pages, item.pages)
|
||||
// acc['id'] = item.author.id
|
||||
// acc['login'] = item.author.login
|
||||
// acc['post'] = item.author.post
|
||||
// acc['fio'] = splitname(item.author)
|
||||
// acc['count'] += item.count
|
||||
// acc['session'] = Object.keys(yearpages).length
|
||||
// }
|
||||
// return acc
|
||||
// }, {count: 0})
|
||||
|
||||
let arrbigs = []
|
||||
pages.map(namepages => {
|
||||
let onetooltip = {
|
||||
namepages: "",
|
||||
count: 0,
|
||||
unic: 0
|
||||
}
|
||||
// let arrbigs = []
|
||||
// pages.map(namepages => {
|
||||
// let onetooltip = {
|
||||
// namepages: "",
|
||||
// count: 0,
|
||||
// unic: 0
|
||||
// }
|
||||
|
||||
let unicpages = user.filter(e => (e.pages == namepages))
|
||||
// let unicpages = user.filter(e => (e.pages == namepages))
|
||||
|
||||
const pagesData = unicpages.reduce((accpag, pag) => {
|
||||
accpag['pages'] = pag.pages
|
||||
accpag['count'] += pag.count
|
||||
accpag['unic'] += 1
|
||||
return accpag
|
||||
}, {count: 0, unic: 0})
|
||||
// const pagesData = unicpages.reduce((accpag, pag) => {
|
||||
// accpag['pages'] = pag.pages
|
||||
// accpag['count'] += pag.count
|
||||
// accpag['unic'] += 1
|
||||
// return accpag
|
||||
// }, {count: 0, unic: 0})
|
||||
|
||||
onetooltip.namepages = pagesData.pages
|
||||
onetooltip.count = pagesData.count
|
||||
onetooltip.unic = pagesData.unic
|
||||
arrbigs.push(onetooltip)
|
||||
}
|
||||
)
|
||||
activuser.user.id = groupUser.id
|
||||
activuser.user.login = groupUser.login
|
||||
activuser.user.post = groupUser.post
|
||||
activuser.user.fio = groupUser.fio
|
||||
activuser.info.count = groupUser.count
|
||||
activuser.info.session = groupUser.session
|
||||
activuser.info.pages = user.length
|
||||
activuser.tooltip = arrbigs
|
||||
dataActivusers.value.push(activuser)
|
||||
})
|
||||
}
|
||||
// onetooltip.namepages = pagesData.pages
|
||||
// onetooltip.count = pagesData.count
|
||||
// onetooltip.unic = pagesData.unic
|
||||
// arrbigs.push(onetooltip)
|
||||
// }
|
||||
// )
|
||||
// activuser.user.id = groupUser.id
|
||||
// activuser.user.login = groupUser.login
|
||||
// activuser.user.post = groupUser.post
|
||||
// activuser.user.fio = groupUser.fio
|
||||
// activuser.info.count = groupUser.count
|
||||
// activuser.info.session = groupUser.session
|
||||
// activuser.info.pages = user.length
|
||||
// activuser.tooltip = arrbigs
|
||||
// dataActivusers.value.push(activuser)
|
||||
// })
|
||||
// }
|
||||
|
||||
const funyearpages = (data, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
if (!data[item.visitdate]) {
|
||||
data[item.visitdate] = {}
|
||||
}
|
||||
if (!data[item.visitdate][item.pages]) {
|
||||
data[item.visitdate][item.pages] = 0
|
||||
}
|
||||
// const funyearpages = (data, item) => {
|
||||
// if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
// if (!data[item.visitdate]) {
|
||||
// data[item.visitdate] = {}
|
||||
// }
|
||||
// if (!data[item.visitdate][item.pages]) {
|
||||
// data[item.visitdate][item.pages] = 0
|
||||
// }
|
||||
|
||||
data[item.visitdate][item.pages] += item.count
|
||||
}
|
||||
// data[item.visitdate][item.pages] += item.count
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
const data_collection = (data, obj) => {
|
||||
let attendance = {
|
||||
today: {
|
||||
title: 'сегодня',
|
||||
user: [],
|
||||
proc: 0
|
||||
},
|
||||
period: {
|
||||
title: 'за период',
|
||||
user: [],
|
||||
proc: 0,
|
||||
previos: 0
|
||||
},
|
||||
// const data_collection = (data, obj) => {
|
||||
// let attendance = {
|
||||
// today: {
|
||||
// title: 'сегодня',
|
||||
// user: [],
|
||||
// proc: 0
|
||||
// },
|
||||
// period: {
|
||||
// title: 'за период',
|
||||
// user: [],
|
||||
// proc: 0,
|
||||
// previos: 0
|
||||
// },
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
const groupedData = data.reduce((acc, item) => {
|
||||
// const groupedData = data.reduce((acc, item) => {
|
||||
|
||||
if (!acc[item.pages]) {
|
||||
acc[item.pages] = {
|
||||
now:
|
||||
{unique: [], countall: 0},
|
||||
year:
|
||||
{unique: [], countall: 0}
|
||||
}
|
||||
}
|
||||
// if (!acc[item.pages]) {
|
||||
// acc[item.pages] = {
|
||||
// now:
|
||||
// {unique: [], countall: 0},
|
||||
// year:
|
||||
// {unique: [], countall: 0}
|
||||
// }
|
||||
// }
|
||||
|
||||
if (obj) {
|
||||
funLineChart(obj, item)
|
||||
}
|
||||
// if (obj) {
|
||||
// funLineChart(obj, item)
|
||||
// }
|
||||
|
||||
if (item.visitdate >= formatDash(filterStore.date_period.startdate) && item.visitdate <= formatDash(filterStore.date_period.enddate)){
|
||||
checking_for_entry(unicuser.value, item.author.id)
|
||||
// if (item.visitdate >= formatDash(filterStore.date_period.startdate) && item.visitdate <= formatDash(filterStore.date_period.enddate)){
|
||||
// checking_for_entry(unicuser.value, item.author.id)
|
||||
|
||||
checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
|
||||
acc[item.pages].year.countall += item.count
|
||||
// checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
|
||||
// acc[item.pages].year.countall += item.count
|
||||
|
||||
checking_for_entry(attendance.period.user, splitname(item.author))
|
||||
}
|
||||
// checking_for_entry(attendance.period.user, splitname(item.author))
|
||||
// }
|
||||
|
||||
if (item.visitdate == formatDash(new Date())) {
|
||||
// console.log(item, 'item');
|
||||
// if (item.visitdate == formatDash(new Date())) {
|
||||
// // console.log(item, 'item');
|
||||
|
||||
checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
|
||||
acc[item.pages].now.countall += item.count
|
||||
// checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
|
||||
// acc[item.pages].now.countall += item.count
|
||||
|
||||
checking_for_entry(attendance.today.user, splitname(item.author))
|
||||
}
|
||||
// checking_for_entry(attendance.today.user, splitname(item.author))
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return acc
|
||||
}, {})
|
||||
let proctoday = (attendance.today.user.length*100)/for_formulas.value.staff
|
||||
let procperiod = (attendance.period.user.length*100)/for_formulas.value.staff
|
||||
attendance.today.proc = `${Number.isInteger(proctoday)?proctoday:(proctoday).toFixed(2)}%`
|
||||
attendance.period.proc = `${Number.isInteger(procperiod)?procperiod:(procperiod).toFixed(2)}%`
|
||||
// return acc
|
||||
// }, {})
|
||||
// let proctoday = (attendance.today.user.length*100)/for_formulas.value.staff
|
||||
// let procperiod = (attendance.period.user.length*100)/for_formulas.value.staff
|
||||
// attendance.today.proc = `${Number.isInteger(proctoday)?proctoday:(proctoday).toFixed(2)}%`
|
||||
// attendance.period.proc = `${Number.isInteger(procperiod)?procperiod:(procperiod).toFixed(2)}%`
|
||||
|
||||
let previos = (for_formulas.value.previos*100)/attendance.period.user.length
|
||||
attendance.period.previos = 100- (Number.isInteger(previos)?previos:(previos).toFixed(2))
|
||||
dataAttendance.value = attendance
|
||||
// console.log(attendance, 'attendance[splitname(item.author)]')
|
||||
return groupedData
|
||||
}
|
||||
// let previos = (for_formulas.value.previos*100)/attendance.period.user.length
|
||||
// attendance.period.previos = 100- (Number.isInteger(previos)?previos:(previos).toFixed(2))
|
||||
// dataAttendance.value = attendance
|
||||
// // console.log(attendance, 'attendance[splitname(item.author)]')
|
||||
// return groupedData
|
||||
// }
|
||||
|
||||
|
||||
|
||||
const visitionreduce = () => {
|
||||
// const visitionreduce = () => {
|
||||
|
||||
let lineCharts = {}
|
||||
// let lineCharts = {}
|
||||
|
||||
unicuser.value = []
|
||||
// unicuser.value = []
|
||||
|
||||
|
||||
pages_count.value.data= data_collection(visiting.value, lineCharts)
|
||||
// pages_count.value.data= data_collection(visiting.value, lineCharts)
|
||||
|
||||
const gruppitovka= () => {
|
||||
console.log(visiting.value, 'dataLineChart');
|
||||
}
|
||||
gruppitovka()
|
||||
// // const gruppitovka= () => {
|
||||
// // console.log(visiting.value, 'dataLineChart');
|
||||
// // }
|
||||
// // gruppitovka()
|
||||
|
||||
Object.entries(lineCharts).map(e=> {
|
||||
lineCharts[e[0]].crr = dataChart.value[e[0]].crr
|
||||
lineCharts[e[0]].br = dataChart.value[e[0]].br
|
||||
lineCharts[e[0]].ppv = dataChart.value[e[0]].ppv
|
||||
})
|
||||
// Object.entries(lineCharts).map(e=> {
|
||||
// lineCharts[e[0]].crr = dataChart.value[e[0]].crr
|
||||
// lineCharts[e[0]].br = dataChart.value[e[0]].br
|
||||
// lineCharts[e[0]].ppv = dataChart.value[e[0]].ppv
|
||||
// })
|
||||
|
||||
dataLineChart.value = lineCharts
|
||||
// dataLineChart.value = lineCharts
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
|
||||
if(newValue){
|
||||
visition()
|
||||
visitionreduce()
|
||||
title_period()
|
||||
}
|
||||
}, {deep:true})
|
||||
// watch(()=>filterStore.date_period,(newValue,oldValue)=>{
|
||||
// if(newValue){
|
||||
// visition()
|
||||
// visitionreduce()
|
||||
// title_period()
|
||||
// }
|
||||
// }, {deep:true})
|
||||
|
||||
|
||||
const title_period = () => {
|
||||
selected_days.value.year.start = formatComa(filterStore.date_period.startdate)
|
||||
selected_days.value.year.end = formatComa(filterStore.date_period.enddate)
|
||||
pages_count.value.title = selected_days.value
|
||||
}
|
||||
// const title_period = () => {
|
||||
// selected_days.value.year.start = formatComa(filterStore.date_period.startdate)
|
||||
// selected_days.value.year.end = formatComa(filterStore.date_period.enddate)
|
||||
// pages_count.value.title = selected_days.value
|
||||
// }
|
||||
|
||||
title_period()
|
||||
// title_period()
|
||||
|
||||
|
||||
|
||||
return {
|
||||
visiting,
|
||||
pages_count,
|
||||
visitionreduce,
|
||||
dataLineChart,
|
||||
dataActivusers,
|
||||
formatComa,
|
||||
selected_days,
|
||||
for_formulas,
|
||||
dataAttendance,
|
||||
dataIndicators,
|
||||
dataChart,
|
||||
feedback
|
||||
// countgrupp,
|
||||
// activuser,
|
||||
|
||||
// feedback,
|
||||
// traffic,
|
||||
// crit,
|
||||
// visition,
|
||||
|
||||
|
||||
// icons,
|
||||
// periodname,
|
||||
// weekstart,
|
||||
// selected_days,
|
||||
// modelrating,
|
||||
// pages_count
|
||||
|
||||
|
||||
alldata
|
||||
// visiting,
|
||||
// pages_count,
|
||||
// visitionreduce,
|
||||
// dataLineChart,
|
||||
// dataActivusers,
|
||||
// formatComa,
|
||||
// selected_days,
|
||||
// for_formulas,
|
||||
// dataAttendance,
|
||||
// dataIndicators,
|
||||
// dataChart,
|
||||
// feedback,
|
||||
// filter
|
||||
|
||||
}
|
||||
// const pages_count = ref({})
|
||||
|
||||
// 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 < formatDash(enddate.value)) {
|
||||
// last_day.push(e.visitdate)
|
||||
// }
|
||||
|
||||
// })
|
||||
// last_days.value = last_day[last_day.length-1]
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 == formatDash(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 ==formatDash(last_days.value)){
|
||||
// portal_traffic.now.comparison_period.add(item.author.id)
|
||||
// portal_traffic.now.info = `за ${formatComa(last_days.value)}`
|
||||
// }
|
||||
// portal_traffic.year.info = `с ${formatComa(previous_period.value)} по ${formatComa(startdate.value)} `
|
||||
// console.log( `${formatComa(previous_period.value)} >=${formatComa(item.visitdate)} <= ${formatComa(startdate.value)}`,'до')
|
||||
|
||||
|
||||
// Посещаемость портала для периода - выбранный период фильтра
|
||||
// if (item.visitdate >= formatDash(previous_period.value) && item.visitdate < formatDash(startdate.value)) {
|
||||
// console.log( `${formatComa(previous_period.value)} >=${formatComa(item.visitdate)} < ${formatComa(startdate.value)}`,'после')
|
||||
// console.log(previous_period.value, formatDash(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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,600 @@
|
||||
<template>
|
||||
<v-row v-if="Object.keys(feedback).length==0">
|
||||
<v-col class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light">
|
||||
<v-progress-circular
|
||||
:size="150"
|
||||
:width="7"
|
||||
color="cyan-darken-3"
|
||||
indeterminate
|
||||
></v-progress-circular>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="flex-column gap ma-1" v-else>
|
||||
<toolbar-filter/>
|
||||
<v-col lg=3 class="w100">
|
||||
<v-row no-gutters class="h-100 gap">
|
||||
<v-col >
|
||||
<portal-traffic :traffic=dataAttendance />
|
||||
</v-col>
|
||||
<v-col lg=9>
|
||||
|
||||
<line-chart :dataLineChart="dataLineChart" :dataChart="dataChart"/>
|
||||
</v-col>
|
||||
<v-col >
|
||||
<v-btn block class="text-caption" @click="filter='year'">Год</v-btn>
|
||||
<v-btn block class="text-caption" @click="filter='month'">Месяц</v-btn>
|
||||
<v-btn block class="text-caption" @click="filter='day'">День</v-btn>
|
||||
<my-helper :pretext="dataAttendance"/>
|
||||
{{filter}}
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-col class="w100 ">
|
||||
|
||||
<v-row no-gutters class="h-100 gap">
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class="flex-column gap" >
|
||||
<v-col v-for="x in dataIndicators" :key=x>
|
||||
<card-total :indicator=x />
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
</v-col>
|
||||
<v-col lg=4 class="d-flex flex-column">
|
||||
<rating-page :pages_count=pages_count />
|
||||
</v-col>
|
||||
<v-col lg=4 class="d-flex flex-column ">
|
||||
|
||||
<top-user
|
||||
:activusers = dataActivusers
|
||||
|
||||
/>
|
||||
|
||||
</v-col>
|
||||
<v-col lg=2 class="d-flex flex-column">
|
||||
<feedmodul
|
||||
:feedback="feedback"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
import {pagecounter, splitname, formatComa, formatDash} from '@/utils/universal_functions'
|
||||
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { usePortalFilterStore } from '@/store/AboutPortalFilter'
|
||||
|
||||
import Feedmodul from '@/components/UI/aboutportal/feedmodul.vue'
|
||||
import DateSelect from '@/components/UI/date-select.vue'
|
||||
import TopUser from '@/components/UI/aboutportal/top-user.vue'
|
||||
import LineChart from '@/components/UI/aboutportal/line-chart.vue'
|
||||
import PortalTraffic from '@/components/UI/aboutportal/portal-traffic.vue'
|
||||
import ToolbarFilter from '@/components/UI/aboutportal/toolbar-filter.vue'
|
||||
import RatingPage from '@/components/UI/aboutportal/rating-page.vue'
|
||||
|
||||
import CardTotal from '@/components/UI/aboutportal/card-total.vue'
|
||||
// import Feedmodul from '@/components/UI/aboutportal/feedmodul.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Feedmodul,
|
||||
DateSelect,
|
||||
TopUser,
|
||||
LineChart,
|
||||
PortalTraffic,
|
||||
ToolbarFilter,
|
||||
RatingPage,
|
||||
|
||||
CardTotal,
|
||||
// Feedmodul
|
||||
},
|
||||
|
||||
|
||||
setup(){
|
||||
const filterStore = usePortalFilterStore()
|
||||
const filter = ref('day')
|
||||
const visiting = ref([])
|
||||
const feedback = ref([])
|
||||
const for_formulas = ref({})
|
||||
|
||||
const dataLineChart = ref({})
|
||||
const dataActivusers = ref([])
|
||||
const dataAttendance = ref({})
|
||||
const dataIndicators = ref({})
|
||||
const dataChart = ref({})
|
||||
|
||||
const unicuser = ref([])
|
||||
|
||||
const selected_days = ref({today: 'сегодня', year: {start: new Date(), end: new Date()}})
|
||||
const pages_count = ref({data: {}, title: {}})
|
||||
|
||||
|
||||
pagecounter()
|
||||
|
||||
const visition = () => {
|
||||
|
||||
axiosApiInstance.get(`api/watcher/counter/?start=${formatDash(filterStore.date_period.startdate)}&end=${formatDash(filterStore.date_period.enddate)}`).then(result => {
|
||||
for_formulas.value = result.data.for_formulas
|
||||
visiting.value = result.data.result
|
||||
feedback.value = result.data.feedback
|
||||
dataIndicators.value = result.data.indicators
|
||||
dataChart.value = result.data.chart,
|
||||
console.log(result.data, 'result.data');
|
||||
|
||||
visitionreduce()
|
||||
funActiveUser()
|
||||
|
||||
})}
|
||||
|
||||
visition()
|
||||
|
||||
const checking_for_entry = (where, what) => {
|
||||
if (!where.includes(what))
|
||||
{
|
||||
where.push(what)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
const funLineChart = (data, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
if (!data[item.visitdate]) {
|
||||
data[item.visitdate] = {count: 0, unic: []}
|
||||
}
|
||||
checking_for_entry(data[item.visitdate]['unic'], splitname(item.author))
|
||||
data[item.visitdate].count += item.count
|
||||
}
|
||||
}
|
||||
|
||||
const funActiveUser = () => {
|
||||
dataActivusers.value = []
|
||||
unicuser.value.map(iduser => {
|
||||
|
||||
let activuser ={
|
||||
user: {
|
||||
id: "",
|
||||
login: "",
|
||||
post: "",
|
||||
fio: ""
|
||||
},
|
||||
info: {
|
||||
count: 0,
|
||||
session: 0,
|
||||
pages: 0
|
||||
},
|
||||
tooltip: [],
|
||||
}
|
||||
|
||||
let yearpages = {}
|
||||
let pages = []
|
||||
let user = visiting.value.filter(e => e.author.id == iduser)
|
||||
|
||||
const groupUser = user.reduce((acc, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
funyearpages(yearpages, item)
|
||||
checking_for_entry(pages, item.pages)
|
||||
acc['id'] = item.author.id
|
||||
acc['login'] = item.author.login
|
||||
acc['post'] = item.author.post
|
||||
acc['fio'] = splitname(item.author)
|
||||
acc['count'] += item.count
|
||||
acc['session'] = Object.keys(yearpages).length
|
||||
}
|
||||
return acc
|
||||
}, {count: 0})
|
||||
|
||||
let arrbigs = []
|
||||
pages.map(namepages => {
|
||||
let onetooltip = {
|
||||
namepages: "",
|
||||
count: 0,
|
||||
unic: 0
|
||||
}
|
||||
|
||||
let unicpages = user.filter(e => (e.pages == namepages))
|
||||
|
||||
const pagesData = unicpages.reduce((accpag, pag) => {
|
||||
accpag['pages'] = pag.pages
|
||||
accpag['count'] += pag.count
|
||||
accpag['unic'] += 1
|
||||
return accpag
|
||||
}, {count: 0, unic: 0})
|
||||
|
||||
onetooltip.namepages = pagesData.pages
|
||||
onetooltip.count = pagesData.count
|
||||
onetooltip.unic = pagesData.unic
|
||||
arrbigs.push(onetooltip)
|
||||
}
|
||||
)
|
||||
activuser.user.id = groupUser.id
|
||||
activuser.user.login = groupUser.login
|
||||
activuser.user.post = groupUser.post
|
||||
activuser.user.fio = groupUser.fio
|
||||
activuser.info.count = groupUser.count
|
||||
activuser.info.session = groupUser.session
|
||||
activuser.info.pages = user.length
|
||||
activuser.tooltip = arrbigs
|
||||
dataActivusers.value.push(activuser)
|
||||
})
|
||||
}
|
||||
|
||||
const funyearpages = (data, item) => {
|
||||
if (item.visitdate <= formatDash(filterStore.date_period.enddate)) {
|
||||
if (!data[item.visitdate]) {
|
||||
data[item.visitdate] = {}
|
||||
}
|
||||
if (!data[item.visitdate][item.pages]) {
|
||||
data[item.visitdate][item.pages] = 0
|
||||
}
|
||||
|
||||
data[item.visitdate][item.pages] += item.count
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const data_collection = (data, obj) => {
|
||||
let attendance = {
|
||||
today: {
|
||||
title: 'сегодня',
|
||||
user: [],
|
||||
proc: 0
|
||||
},
|
||||
period: {
|
||||
title: 'за период',
|
||||
user: [],
|
||||
proc: 0,
|
||||
previos: 0
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
const groupedData = data.reduce((acc, item) => {
|
||||
|
||||
if (!acc[item.pages]) {
|
||||
acc[item.pages] = {
|
||||
now:
|
||||
{unique: [], countall: 0},
|
||||
year:
|
||||
{unique: [], countall: 0}
|
||||
}
|
||||
}
|
||||
|
||||
if (obj) {
|
||||
funLineChart(obj, item)
|
||||
}
|
||||
|
||||
if (item.visitdate >= formatDash(filterStore.date_period.startdate) && item.visitdate <= formatDash(filterStore.date_period.enddate)){
|
||||
checking_for_entry(unicuser.value, item.author.id)
|
||||
|
||||
checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
|
||||
acc[item.pages].year.countall += item.count
|
||||
|
||||
checking_for_entry(attendance.period.user, splitname(item.author))
|
||||
}
|
||||
|
||||
if (item.visitdate == formatDash(new Date())) {
|
||||
// console.log(item, 'item');
|
||||
|
||||
checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
|
||||
acc[item.pages].now.countall += item.count
|
||||
|
||||
checking_for_entry(attendance.today.user, splitname(item.author))
|
||||
}
|
||||
|
||||
|
||||
|
||||
return acc
|
||||
}, {})
|
||||
let proctoday = (attendance.today.user.length*100)/for_formulas.value.staff
|
||||
let procperiod = (attendance.period.user.length*100)/for_formulas.value.staff
|
||||
attendance.today.proc = `${Number.isInteger(proctoday)?proctoday:(proctoday).toFixed(2)}%`
|
||||
attendance.period.proc = `${Number.isInteger(procperiod)?procperiod:(procperiod).toFixed(2)}%`
|
||||
|
||||
let previos = (for_formulas.value.previos*100)/attendance.period.user.length
|
||||
attendance.period.previos = 100- (Number.isInteger(previos)?previos:(previos).toFixed(2))
|
||||
dataAttendance.value = attendance
|
||||
// console.log(attendance, 'attendance[splitname(item.author)]')
|
||||
return groupedData
|
||||
}
|
||||
|
||||
|
||||
|
||||
const visitionreduce = () => {
|
||||
|
||||
let lineCharts = {}
|
||||
|
||||
unicuser.value = []
|
||||
|
||||
|
||||
pages_count.value.data= data_collection(visiting.value, lineCharts)
|
||||
|
||||
// const gruppitovka= () => {
|
||||
// console.log(visiting.value, 'dataLineChart');
|
||||
// }
|
||||
// gruppitovka()
|
||||
|
||||
Object.entries(lineCharts).map(e=> {
|
||||
lineCharts[e[0]].crr = dataChart.value[e[0]].crr
|
||||
lineCharts[e[0]].br = dataChart.value[e[0]].br
|
||||
lineCharts[e[0]].ppv = dataChart.value[e[0]].ppv
|
||||
})
|
||||
|
||||
dataLineChart.value = lineCharts
|
||||
|
||||
|
||||
}
|
||||
|
||||
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
|
||||
if(newValue){
|
||||
visition()
|
||||
visitionreduce()
|
||||
title_period()
|
||||
}
|
||||
}, {deep:true})
|
||||
|
||||
|
||||
const title_period = () => {
|
||||
selected_days.value.year.start = formatComa(filterStore.date_period.startdate)
|
||||
selected_days.value.year.end = formatComa(filterStore.date_period.enddate)
|
||||
pages_count.value.title = selected_days.value
|
||||
}
|
||||
|
||||
title_period()
|
||||
|
||||
|
||||
|
||||
return {
|
||||
visiting,
|
||||
pages_count,
|
||||
visitionreduce,
|
||||
dataLineChart,
|
||||
dataActivusers,
|
||||
formatComa,
|
||||
selected_days,
|
||||
for_formulas,
|
||||
dataAttendance,
|
||||
dataIndicators,
|
||||
dataChart,
|
||||
feedback,
|
||||
filter
|
||||
// countgrupp,
|
||||
// activuser,
|
||||
|
||||
// feedback,
|
||||
// traffic,
|
||||
// crit,
|
||||
// visition,
|
||||
|
||||
|
||||
// icons,
|
||||
// periodname,
|
||||
// weekstart,
|
||||
// selected_days,
|
||||
// modelrating,
|
||||
// pages_count
|
||||
|
||||
|
||||
}
|
||||
// const pages_count = ref({})
|
||||
|
||||
// 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 < formatDash(enddate.value)) {
|
||||
// last_day.push(e.visitdate)
|
||||
// }
|
||||
|
||||
// })
|
||||
// last_days.value = last_day[last_day.length-1]
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 == formatDash(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 ==formatDash(last_days.value)){
|
||||
// portal_traffic.now.comparison_period.add(item.author.id)
|
||||
// portal_traffic.now.info = `за ${formatComa(last_days.value)}`
|
||||
// }
|
||||
// portal_traffic.year.info = `с ${formatComa(previous_period.value)} по ${formatComa(startdate.value)} `
|
||||
// console.log( `${formatComa(previous_period.value)} >=${formatComa(item.visitdate)} <= ${formatComa(startdate.value)}`,'до')
|
||||
|
||||
|
||||
// Посещаемость портала для периода - выбранный период фильтра
|
||||
// if (item.visitdate >= formatDash(previous_period.value) && item.visitdate < formatDash(startdate.value)) {
|
||||
// console.log( `${formatComa(previous_period.value)} >=${formatComa(item.visitdate)} < ${formatComa(startdate.value)}`,'после')
|
||||
// console.log(previous_period.value, formatDash(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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -112,10 +112,10 @@ class CardUserSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
class ShortUserSerializer(serializers.ModelSerializer):
|
||||
|
||||
# login = serializers.CharField()
|
||||
|
||||
|
||||
class Meta:
|
||||
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = ['familyname', 'name', 'parentname', 'id', 'login', 'post', 'department']
|
||||
fields = ['familyname', 'name', 'parentname', 'id', 'login', 'post', 'department']
|
||||
# fields='__all__'
|
||||
@@ -20,3 +20,18 @@ class VisitdateSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = CountVisitor
|
||||
fields = ['visitdate']
|
||||
|
||||
|
||||
class PagesSerializer(serializers.ModelSerializer):
|
||||
user = serializers.SerializerMethodField('get_user')
|
||||
pages = serializers.CharField(source='pages.page')
|
||||
fullPath = serializers.CharField(source='pages.fullPath')
|
||||
ico = serializers.CharField(source='pages.ico')
|
||||
|
||||
class Meta:
|
||||
model = CountVisitor
|
||||
fields = ['user', 'pages', 'fullPath', 'ico', 'visitdate', 'count']
|
||||
|
||||
def get_user(self, obj):
|
||||
|
||||
return ShortUserSerializer(obj.user.user).data
|
||||
@@ -3,6 +3,7 @@ from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('counter/', Counter.as_view(),name="CountVisitors"),
|
||||
path('testwatcher/', TestwatcherAPIView.as_view(), name="Testwatcher"),
|
||||
path('selectedlinks/', SelectedLinksAPIView.as_view(),name="SelectedLinks")
|
||||
# path('', views.Watchuser.as_view()), selectedlinks
|
||||
|
||||
|
||||
+24
-27
@@ -21,7 +21,7 @@ class Counter(ListAPIView):
|
||||
|
||||
|
||||
def get(self, request):
|
||||
|
||||
|
||||
data_start = datetime.strptime(request.GET.get("start"), "%Y-%m-%d").date()
|
||||
data_end = datetime.strptime(request.GET.get("end"), "%Y-%m-%d").date()
|
||||
beetween = datetime.strptime(request.GET.get("end"), "%Y-%m-%d").date() - (data_start + timedelta(days=1))
|
||||
@@ -34,11 +34,12 @@ class Counter(ListAPIView):
|
||||
new_date_end = data_start - timedelta(days=1)
|
||||
|
||||
# Посещаемость портала
|
||||
# res=CountVisitor.objects.all()
|
||||
res = CountVisitor.objects.filter(Q(visitdate__lte = request.GET.get("end")) | Q(visitdate=date.today()))
|
||||
visiting = res.filter(visitdate__gte=request.GET.get("start"))
|
||||
formulas = data_start
|
||||
indicators={}
|
||||
print(formulas.strftime("%Y-%m-%d"),'--------------')
|
||||
# print(formulas, 'formulasformulas')
|
||||
while (formulas <= data_end):
|
||||
indicators[formulas.strftime("%Y-%m-%d")] = {'crr': 0, 'br': 0, 'ppv': 0}
|
||||
|
||||
@@ -59,12 +60,6 @@ class Counter(ListAPIView):
|
||||
if crr_per > 0:
|
||||
indicators[formulas.strftime("%Y-%m-%d")]['br'] = round((br/crr_per)*100, 2)
|
||||
indicators[formulas.strftime("%Y-%m-%d")]['ppv'] = round(ppv/crr_per, 2)
|
||||
# print(br, crr_per, request.GET.get("start"), formulas, '1')
|
||||
|
||||
#
|
||||
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -74,28 +69,19 @@ class Counter(ListAPIView):
|
||||
|
||||
|
||||
formulas += timedelta(days=1)
|
||||
print(indicators, '88888888888888888')
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Обратная связь
|
||||
feed = UserComment.objects.all()
|
||||
rating = RatingStatus.objects.values('crit__name', 'crit__ico', 'crit__color', 'rating').filter(usercom__time_create__range=[request.GET.get("start"), request.GET.get("end")])
|
||||
d = feed.filter(time_create__range=[request.GET.get("start"), request.GET.get("end")])
|
||||
|
||||
# print(, '========================')
|
||||
# print(feed.values_list('user', 'comment').annotate(count_comment=Count('comment')).order_by(F('count_comment').desc(nulls_last=True)).filter(time_create__range=[request.GET.get("start"), request.GET.get("end")]), '------------------------------------------------')
|
||||
|
||||
|
||||
return Response({'result':CountSerializer(visiting, many=True).data,
|
||||
'chart': indicators,
|
||||
# 'today':CountSerializer(nowdate, many=True).data, .aggregate(res=Avg('rating'))
|
||||
|
||||
'feedback': {
|
||||
'feed': UserCommentSerializer(d, many=True).data,
|
||||
#
|
||||
|
||||
'criteria': list(rating.values('crit__name').annotate(ratings=Avg('rating'), name=F('crit__name'), ico=F('crit__ico'), color=F('crit__color')).values('ratings', 'name', 'ico', 'color')),
|
||||
'data': {
|
||||
'score': {
|
||||
@@ -110,7 +96,7 @@ class Counter(ListAPIView):
|
||||
}
|
||||
},
|
||||
'last_comment': feed.values('time_create').filter(~Q(comment='')).latest('time_create'),
|
||||
# 'avg_score': round(avgrating['res'], 2)
|
||||
|
||||
},
|
||||
'for_formulas': {
|
||||
'staff': DictEmployee.objects.filter(deleted=0).count(),
|
||||
@@ -145,9 +131,9 @@ class Counter(ListAPIView):
|
||||
})
|
||||
|
||||
|
||||
# 'data': f"{toFixed((br/crr_per)*100)}%" if is_integer((br/crr_per)*100) == True else f"{round((br/crr_per)*100, 2)}%",
|
||||
# f"{toFixed(crr)}%" if is_integer(crr) == True else f"{round(crr, 2)}%",
|
||||
|
||||
def post(self, request):
|
||||
|
||||
myfullPath = request.data['fullPath']
|
||||
if "?" in myfullPath:
|
||||
myfullPath= myfullPath.split("?")[0]
|
||||
@@ -156,19 +142,18 @@ class Counter(ListAPIView):
|
||||
|
||||
if request.data['user__id'] is not None:
|
||||
watch,create = CountVisitor.objects.get_or_create(user = User(id=request.data['user__id']),pages=page, visitdate=date.today())
|
||||
# else:
|
||||
# watch,create = CountVisitor.objects.get_or_create(user__id__isnull=True, pages=page, visitdate=date.today())
|
||||
|
||||
watch.count+=1
|
||||
watch.save()
|
||||
|
||||
datavisit = CountVisitor.objects.filter(pages=page.id).earliest('visitdate')
|
||||
|
||||
|
||||
res = {"totalvisit": CountVisitor.objects.filter(pages=page.id).aggregate(Sum('count'))['count__sum'],
|
||||
"visittoday":CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).aggregate(Sum('count'))['count__sum'],
|
||||
"uniqtoday" : CountVisitor.objects.filter(visitdate=date.today(), pages=page.id).count(),
|
||||
"visitdate" : VisitdateSerializer(datavisit).data['visitdate']
|
||||
}
|
||||
|
||||
|
||||
return Response(res)
|
||||
|
||||
class SelectedLinksAPIView(ListAPIView):
|
||||
@@ -179,4 +164,16 @@ class SelectedLinksAPIView(ListAPIView):
|
||||
sort = res.order_by('-count__sum')[:20]
|
||||
|
||||
return Response(sort)
|
||||
|
||||
class TestwatcherAPIView(ListAPIView):
|
||||
|
||||
def get(self, request):
|
||||
res = CountVisitor.objects.filter(visitdate__lt = request.GET.get("start")).values('visitdate').annotate(total=Count('user', distinct=True)).order_by('visitdate')
|
||||
per = CountVisitor.objects.filter(Q(visitdate__lte = request.GET.get("end"), visitdate__gte =request.GET.get("start")) | Q(visitdate=date.today()))
|
||||
# print( DictEmployee.objects.filter(Q(deleteddate__isnull= True) | Q(deleteddate__gte = request.GET.get("end"))).count())
|
||||
return Response({
|
||||
'beforperiod': res,
|
||||
'period': PagesSerializer(per, many= True).data,
|
||||
'staff': DictEmployee.objects.filter(Q(deleteddate__isnull= True) | Q(deleteddate__gte = request.GET.get("end"))).count()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user