Начало сборки объекта

This commit is contained in:
iriska-gri committed 2024-02-07 12:03:17 +03:00
1 parent e473f88d03
commit 186e9f8776
1 file changed
+90 -291
+90 -291
View File
@@ -24,175 +24,16 @@
</v-col>
<v-col lg=4 class="d-flex flex-column ">
<top-user
<!-- <top-user
:activusers = dataTopUser
@sortcount=sortcount
/>
<!-- -->
<!--
> -->
/> -->
<!-- <div v-for="(x, key) in dataActivusers" :key="key" >
{{x}}
<top-user
:users = x
:name= key
/>
</div> -->
<!-- </v-card> -->
</v-col>
<v-col class="bg-red">4 </v-col>
</v-row>
</v-col>
<!-- <v-row class="flex-grow-0">
<v-col lg=3>
dataLineChart (данные для графика)-
</v-col>
<v-col> <my-helper :pretext="dataLineChart"/> </v-col>
</v-row> -->
<!-- <v-col class="d-flex flex-column gap">
<v-row no-gutters class="flex-grow-0">
<v-col>
<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 = "startdate"
/>
</div>
по
<div class="px-2 pb-1">
<date-select
@returndate="returnend"
:datedefault = "enddate"
/>
</div>
</v-toolbar>
</v-col>
</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-col lg=3>
<portal-traffic
:traffic=traffic
/>
</v-col>
<v-col>
<line-chart :visiting="visiting"/>
</v-col>
</v-row>
<v-row no-gutters class="gap">
<v-col lg=3>
<feedmodul :feedback="feedback"/>
</v-col>
<v-col class="d-flex flex-column">
<v-row no-gutters class="ma-0 pb-1">
<v-col class="d-flex flex-column">
<v-card class="text-center h-100 d-flex flex-column" >
<v-card-title>
<v-row no-gutters class="">
<v-col lg=2>
<v-switch
v-model="modelrating"
hide-details
density="comfortable"
:label="modelrating?'уникальные':'всего'"
/>
</v-col>
<v-col class="ml-n7 pt-2">
Рейтинг посещаемости страниц портала
</v-col>
</v-row>
</v-card-title>
<v-divider/>
<v-row class=" overflow-auto h-0">
<v-col>
<v-table fixed-header
height="430px">
<thead>
<tr class="text-uppercase">
<th>Имя страницы</th>
<th class="text-center"> на {{selected_days.today}} </th>
<th class="text-center">за период</th>
</tr>
</thead>
<tbody>
<tr v-for="(val, key) in pages_count" :key = key>
<td class="text-left">{{key}}</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>
</v-table>
</v-col>
</v-row>
</v-card>
</v-col>
</v-row>
<v-row no-gutters class="ma-0 flex-grow-0 gap" >
<template v-for="(val, key) in activuser()" >
<v-col v-if = "Object.keys(activuser()).indexOf(key)<3" :key = key>
<top-user
:users="val"
:ico="icons[Object.keys(activuser()).indexOf(key)]"
name="Активность"
/>
</v-col>
</template>
</v-row>
</v-col>
</v-row> -->
<!-- </v-col> -->
</v-row>
</template>
@@ -233,9 +74,8 @@ setup(){
const staff = ref(0)
const dataLineChart = ref({})
const dataActivusers = ref({})
const dataTopUser = ref({})
const dataTopUsers = ref([])
const dataActivusers = ref([])
const unicuser = ref([])
const previous = ref({start: new Date(), end: new Date()})
const selected_days = ref({today: 'сегодня', year: {start: new Date(), end: new Date()}})
@@ -247,7 +87,6 @@ setup(){
if (filterStore.date_period.startdate == filterStore.date_period.enddate) {
days_between = 1
}
// console.log(days_between, 'days_between');
previous.value.start = new Date(new Date(filterStore.date_period.startdate).setDate(new Date(filterStore.date_period.startdate).getDate() - days_between))
previous.value.end = new Date(new Date(filterStore.date_period.startdate).setDate(new Date(filterStore.date_period.startdate).getDate() - 1))
}
@@ -261,6 +100,7 @@ setup(){
visiting.value = result.data.result
feedback.value = result.data.feedback
visitionreduce()
funActiveUser()
})}
@@ -273,164 +113,124 @@ setup(){
}
}
const visitionreduce = () => {
previous_period()
let lineCharts = {}
let activusers = {}
let top_user = {}
let top_users = []
let minitooltip = {}
const funLineChart = (data, item) => {
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 = (data, onedata, item) => {
unicuser.value.map(iduser => {
let activuser ={
user: {
id: "",
login: "",
post: "",
fio: ""
},
info: {
count: 0,
session: 0,
pages: 0
},
tooltip: [
{
namepages: "",
count: 0,
unic: 0
}],
}
let user = visiting.value.filter(e => e.author.id == iduser)
const groupUser = user.reduce((acc, item) => {
acc['id'] = item.author.id
acc['login'] = item.author.login
acc['post'] = item.author.post
acc['fio'] = splitname(item.author)
// console.log(item.author.id, '----------1');
// activuser.user.id = item.author.id
//
return acc
}, {})
activuser.user.id = groupUser.id
activuser.user.login = groupUser.login
activuser.user.post = groupUser.post
activuser.user.fio = groupUser.fio
console.log(groupUser, '----------1');
dataActivusers.value.push(activuser)
console.log(dataActivusers.value, '----------2');
})
}
const visitionreduce = () => {
previous_period()
let lineCharts = {}
let oneUser = {}
console.log(visiting.value)
const groupedData = visiting.value.reduce((acc, item) => {
// Данные для графика по фильтру
if (item.visitdate >= format2(filterStore.date_period.startdate) && item.visitdate <= format2(filterStore.date_period.enddate)){
// ------------------------------
if (!lineCharts[item.visitdate]) {
lineCharts[item.visitdate] = {count: 0, unic: []}
}
funLineChart(lineCharts, item)
checking_for_entry(unicuser.value, item.author.id)
// funActiveUser(activeUser, oneUser, item)
checking_for_entry(lineCharts[item.visitdate]['unic'], splitname(item.author))
// ------------------------------
if (!activusers[splitname(item.author)])
{
activusers[splitname(item.author)] = {session: {} }
}
if (!minitooltip[splitname(item.author)])
{
minitooltip[splitname(item.author)] = {tooltip: {} }
}
if (!activusers[splitname(item.author)].session[item.visitdate]) {
activusers[splitname(item.author)].session[item.visitdate] = {pages: {}}
}
if (!activusers[splitname(item.author)].session[item.visitdate].pages[item.pages]) {
activusers[splitname(item.author)].session[item.visitdate].pages[item.pages] = {count: 0}
}
activusers[splitname(item.author)].session[item.visitdate].pages[item.pages].count = item.count
// ------------------------------
if (!top_user[splitname(item.author)]) {
top_user[splitname(item.author)] = { user: {}, info: {count: 0}, tooltip: []}
}
top_user[splitname(item.author)].user.login = item.author.login
top_user[splitname(item.author)].user.post = item.author.post
top_user[splitname(item.author)].user.fio = splitname(item.author)
top_user[splitname(item.author)].info.count += item.count
// Данные для таблицы по страницам
if (!acc[item.pages]) {
acc[item.pages] = {
now:
{unique: [], countall: 0},
{unique: [], countall: 0},
year:
{unique: [], countall: 0}
{unique: [], countall: 0}
}
}
checking_for_entry(acc[item.pages].year.unique, splitname(item.author))
acc[item.pages].year.countall += item.count
}
// ------------------------------------------------------------------------------------------------------
}
if (item.visitdate == format2(new Date())) {
checking_for_entry(acc[item.pages].now.unique, splitname(item.author))
acc[item.pages].now.countall += item.count
}
dataLineChart.value = lineCharts
dataActivusers.value = activusers
dataTopUser.value = top_user
return acc
}, {})
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
dataLineChart.value = lineCharts
pages_count.value.data = groupedData
}
watch(()=>filterStore.date_period,(newValue,oldValue)=>{
if(newValue){
visitionreduce()
title_period()
}
}, {deep:true})
pages_count.value.data = groupedData
tooltipinfo()
return groupedData
}
const tooltipinfo = () => {
Object.entries(dataActivusers.value).reduce((acc, item) => {
dataTopUser.value[item[0]].info.session = Object.keys(item[1].session).length
Object.entries(item[1].session).reduce((acc_data, data) => {
if(!acc_data[item[0]]) {
acc_data[item[0]] =0
}
acc_data[item[0]] += Object.keys(data[1].pages).length
Object.entries(data[1].pages).map(e => {
if (!minitooltip[e[0]])
{
minitooltip[e[0]] = {count: 0, unic: 0, namepages: '' }
}
minitooltip[e[0]].count += data[1].pages[e[0]].count
minitooltip[e[0]].unic +=1
minitooltip[e[0]].namepages = e[0]
// if (!dataTopUser.value[item[0]].tooltip[e[0]])
// {
// dataTopUser.value[item[0]].tooltip[e[0]] = {count: 0, unic: 0, namepages: '' }
// }
// dataTopUser.value[item[0]].tooltip[e[0]].count += data[1].pages[e[0]].count
// dataTopUser.value[item[0]].tooltip[e[0]].unic +=1
// dataTopUser.value[item[0]].tooltip[e[0]].namepages = e[0]
}
)
console.log(minitooltip);
// Object.entries(minitooltip).map(e => {
// dataTopUser.value[item[0]].tooltip.push(e[1])
// })
dataTopUser.value[item[0]].info.pages = acc_data[item[0]]
return acc_data
}, {})
// arrfortable()
// const arrfortable = () => {
// console.log(dataTopUser.value, '----')
// }
return acc
}, {})
console.log(dataTopUser.value, '----')
}
const sortcount = () => {
console.log('-------------');
dataTopUser.value = Object.values(dataTopUser.value)
.sort((a,b) => (b.info.count - a.info.count ))
console.log('функция из топ юзер');
}
const title_period = () => {
selected_days.value.year.start = format1(filterStore.date_period.startdate)
selected_days.value.year.end = format1(filterStore.date_period.enddate)
@@ -450,7 +250,6 @@ setup(){
previous,
format1,
selected_days,
dataTopUser,
sortcount
// countgrupp,
// activuser,