Новая статистика

This commit is contained in:
iriska-gri committed 2024-01-19 10:44:55 +03:00
1 parent 50731133f7
commit 651a7ff52e
2 files changed
+113 -62

No files matched your search

@@ -4,6 +4,17 @@ import {useAppStore} from '@/store/app'
import { baseURL } from '@/utils/axios-api' import { baseURL } from '@/utils/axios-api'
import { axiosApiInstance, clearAxios } from '@/utils/axios-api' import { axiosApiInstance, clearAxios } from '@/utils/axios-api'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import moment from 'moment'
export function format1(date) {
return moment(date).format('DD.MM.YYYY')
}
export function format2(date) {
return moment(date).format('YYYY-MM-DD')
}
export function getfromserver(path, reactive){ export function getfromserver(path, reactive){
try{ try{
+102 -62
View File
@@ -31,26 +31,64 @@
</v-toolbar> </v-toolbar>
</v-col> </v-col>
</v-row> </v-row>
<!-- <pre> {{visiting}}</pre> -->
<!-- <my-helper :pretext="countvising"/> -->
<v-row no-gutters class="gap"> <v-row no-gutters class="gap">
<v-col lg=3> <v-col lg=3>
<v-card <v-card
class="text-center" class="text-center"
title="Количество посещений"
height="200px" height="200px"
> >
<v-list class="text-start text-subtitle-1 pt-0"> <v-card-title class="pb-0">
Количество Посетителей
<v-list-item v-for="(val, key) in periodname()" :key = key> </v-card-title>
{{val[0]}} : {{val[1]}} <v-card-subtitle>
(уникальные/всего)
</v-card-subtitle>
<v-card-text class="pl-0">
<v-list density class="text-start text-subtitle-1 pt-0">
<v-list-item >
на
<span class="font-weight-bold">
{{today}}
</span>
: {{countvising['now'][0].size}}
/ {{countvising['now'][1]}}
</v-list-item>
<v-list-item>
с
<span class="font-weight-bold">
{{weekday[0]}}
</span>
по
<span class="font-weight-bold">
{{weekday[1]}}
</span>
: {{countvising['week'][0].size}}
/ {{countvising['week'][1]}}
</v-list-item>
<v-list-item>
с
<span class="font-weight-bold">
{{year[0]}}
</span>
по
<span class="font-weight-bold">
{{year[1]}}
</span>
: {{countvising['year'][0].size}}
/ {{countvising['year'][1]}}
</v-list-item> </v-list-item>
</v-list> </v-list>
</v-card-text>
</v-card> </v-card>
</v-col> </v-col>
<v-col> <v-col>
<v-card class="d-flex flex-column text-center" <v-card
class="d-flex flex-column text-center"
height="200px" height="200px"
> >
<line-graph :data="data" :options="options"/> <line-graph :data="data" :options="options"/>
</v-card> </v-card>
</v-col> </v-col>
@@ -61,7 +99,7 @@
<!-- <v-row > <v-row >
<v-col class="pa-1 d-flex flex-column"> <v-col class="pa-1 d-flex flex-column">
<v-row> <v-row>
<v-col <v-col
@@ -73,14 +111,15 @@
<v-col class=" d-flex flex-column"> <v-col class=" d-flex flex-column">
<v-row> <v-row>
<v-col class="d-flex flex-column"> <v-col class="d-flex flex-column">
<v-card class="text-center h-100" title="Рейтинг посещаемости страниц портала"> <v-card class="text-center h-100" title="Рейтинг посещаемости страниц портала">
<v-table class=""> <v-table class="">
<thead> <thead>
<tr> <tr>
<th>Имя страницы</th> <th>Имя страницы</th>
<th class="text-center">Сегодня</th> <th class="text-center"> на {{today[0]}}</th>
<th class="text-center">На прошлой неделе</th> <th class="text-center">с {{weekday[0]}} по {{weekday[1]}}</th>
<th class="text-center">С начала года</th> <th class="text-center">с {{year[0]}} по {{year[1]}}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -107,7 +146,7 @@
</v-col> </v-col>
</v-row> </v-row>
</v-col> </v-col>
</v-row> --> </v-row>
</v-col> </v-col>
</v-row> </v-row>
<!-- <v-row class="ma-3"> <!-- <v-row class="ma-3">
@@ -217,7 +256,7 @@
<script> <script>
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import {pagecounter, splitname} from '@/utils/universal_functions' import {pagecounter, splitname, format1, format2} from '@/utils/universal_functions'
import moment from 'moment' import moment from 'moment'
import lineGraph from '@/components/graph/line-graph.vue' import lineGraph from '@/components/graph/line-graph.vue'
import { axiosApiInstance } from '@/utils/axios-api' import { axiosApiInstance } from '@/utils/axios-api'
@@ -238,13 +277,14 @@ export default {
setup(){ setup(){
const visiting = ref([]) const visiting = ref([])
const feedback = ref([]) const feedback = ref([])
const countvising = ref({now: 0, week: 0, year: 0}) const countvising = ref({now: [new Set(), 0], week: [new Set(), 0], year: [new Set(), 0]})
const crit = ref([]) const crit = ref([])
const startdate =ref(moment(new Date(new Date().getFullYear(), 0, 1)).format('YYYY-MM-DD')) const startdate =ref(format2(new Date(new Date().getFullYear(), 0, 1)))
const endate =ref(moment(new Date()).format('YYYY-MM-DD')) const endate =ref(format2(new Date()))
const icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline'] const icons = ['mdi-numeric-1-box-outline', 'mdi-numeric-2-box-outline', 'mdi-numeric-3-box-outline']
const today = ref('')
// const previousWeekEnd = moment().subtract(1, 'weeks').endOf('week'); // конец предыдущей недели const weekday = ref('')
const year = ref('')
const arrlines = {} const arrlines = {}
const data = computed({ const data = computed({
@@ -323,11 +363,13 @@ setup(){
const returnstart = (dates) => { const returnstart = (dates) => {
startdate.value = dates startdate.value = dates
periodname()
visition() visition()
} }
const returnend = (dates) => { const returnend = (dates) => {
endate.value = dates endate.value = dates
periodname()
visition() visition()
} }
@@ -339,64 +381,45 @@ setup(){
pagecounter() pagecounter()
const periodname = () => {
let datas = weekstart(endate.value)
let today = `Посетителей на ${moment(endate.value).format('DD.MM.YYYY')} число`
let weekday = `Посетителей с ${moment(datas.WeekStart).format('DD.MM.YYYY')} по ${moment(datas.WeekEnd).format('DD.MM.YYYY')}`
let year = `Посетителей с ${moment(startdate.value).format('DD.MM.YYYY')} по ${moment(endate.value).format('DD.MM.YYYY')}`
return [[today, countvising.value['now']],
[weekday, countvising.value['week']],
[year, countvising.value['year']]
]
}
// const periodname = () => {
// let today = 'Посетителей сегодня:'
// let weekday = 'Посетителей на прошлой неделе'
// if (new Date(endate.value) < new Date() ) {
// today = `Посетителей на ${moment(endate.value).format('DD.MM.YYYY')} число`
// // weekday = `Посетителей с ${moment(previousWeekStart._d).format('DD.MM.YYYY')} по ${moment(previousWeekEnd._d,).format('DD.MM.YYYY')}`
// }
// return [
// {now: [today, countvising.value['now']],
// week: [weekday, countvising.value['week']]
// },
// ]
// }
const countgrupp = () => { const countgrupp = () => {
let us = {} let us = {}
let countall = {now: 0, week: 0, year: 0} let countall = {now: [new Set(), 0], week: [new Set(), 0], year: [new Set(), 0]}
const groupedData = const groupedData =
visiting.value.reduce((acc, item) => { visiting.value.reduce((acc, item) => {
if (!acc[item.pages]) { if (!acc[item.pages]) {
acc[item.pages] = {now: 0, week: 0, year: 0} acc[item.pages] = {now: [new Set(), 0], week: [new Set(), 0], year: [new Set(), 0]}
} }
acc[item.pages]['year'] += item.count acc[item.pages]['year'][0].add(item.author.id)
countall.year += item.count acc[item.pages]['year'][1] += item.count
countall['year'][0].add(item.author.id)
countall['year'][1] += item.count
if (item.visitdate == moment(endate.value).format('YYYY-MM-DD')) { if (item.visitdate == format2(endate.value)) {
acc[item.pages]['now'] += item.count acc[item.pages]['now'][0].add(item.author.id)
countall.now += item.count acc[item.pages]['now'][1] += item.count
countall['now'][0].add(item.author.id)
countall['now'][1] += item.count
} }
let week = weekstart(endate.value) let week = weekstart(endate.value)
if (item.visitdate >= moment(week.WeekStart).format('YYYY-MM-DD') && item.visitdate <= moment(week.WeekEnd).format('YYYY-MM-DD')) { if (item.visitdate >=format2(week.WeekStart) && item.visitdate <= format2(week.WeekEnd)) {
acc[item.pages]['week'] += item.count acc[item.pages]['week'][0].add(item.author.id)
countall.week += item.count acc[item.pages]['week'][1] += item.count
countall['week'][0].add(item.author.id)
countall['week'][1] += item.count
} }
if (!us[splitname(item.author)]) if (!us[splitname(item.author)])
@@ -429,9 +452,23 @@ setup(){
return groupedData return groupedData
} }
// const countgruppsumm = () => {
// countgrupp() const periodname = () => {
// } let datas = weekstart(endate.value)
today.value = 'сегодня'
if (format2(new Date()) != format2(endate.value)) {
today.value = format1(endate.value)
}
weekday.value = [format1(datas.WeekStart), format1(datas.WeekEnd)]
year.value = [format1(startdate.value), format1(endate.value)]
}
periodname()
const activuser = () => { const activuser = () => {
@@ -497,8 +534,11 @@ setup(){
startdate, startdate,
icons, icons,
periodname, periodname,
weekstart,
weekstart today,
weekday,
year
} }
} }