Статистика на сегодня и год
This commit is contained in:
1 parent
f2deef9e5e
commit
f209fc3b87
5 files changed
+130
-89
No files matched your search
Generated
+9
@@ -15,6 +15,7 @@
|
||||
"chart.js": "^4.4.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"express-vue": "^5.12.0",
|
||||
"moment": "^2.29.4",
|
||||
"pinia": "^2.0.23",
|
||||
"roboto-fontface": "*",
|
||||
"v-tooltip": "^2.1.3",
|
||||
@@ -13648,6 +13649,14 @@
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/moment": {
|
||||
"version": "2.29.4",
|
||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/move-concurrently": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
"chart.js": "^4.4.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"express-vue": "^5.12.0",
|
||||
"moment": "^2.29.4",
|
||||
"pinia": "^2.0.23",
|
||||
"roboto-fontface": "*",
|
||||
"v-tooltip": "^2.1.3",
|
||||
|
||||
@@ -1,87 +1,128 @@
|
||||
<template>
|
||||
<!-- <div id="app">
|
||||
<a href="#" id="return-top" v-scroll-to="'#top'">Top</a>
|
||||
<div ref="top">Hi. I'm #top</div> -->
|
||||
<!-- </div> -->
|
||||
<v-row>
|
||||
<v-col
|
||||
class="ma-3"
|
||||
class="d-flex flex-column"
|
||||
lg=3
|
||||
>
|
||||
|
||||
{{visiting}}
|
||||
<!-- <v-table density="compact" class="mt-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
Страница
|
||||
</th>
|
||||
<th class="text-left">
|
||||
Количество посещений
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in visiting.pages"
|
||||
:key="item.name"
|
||||
>
|
||||
<td>{{ item.page }}</td>
|
||||
<td>{{ item.count__sum }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</v-table> -->
|
||||
|
||||
<!-- <v-table density="compact" class="mt-3">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">
|
||||
Пользователь
|
||||
</th>
|
||||
<th class="text-left">
|
||||
Страница
|
||||
</th>
|
||||
<th class="text-left">
|
||||
Количество посещений
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in visiting.users"
|
||||
:key="item.name"
|
||||
>
|
||||
<td>{{ item.user__username }}</td>
|
||||
<td>{{ item.page }}</td>
|
||||
<td>{{ item.count__sum }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</v-table> -->
|
||||
|
||||
<v-row class="flex-grow-0">
|
||||
<v-col class="bg-orange">
|
||||
1
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col class="bg-red">
|
||||
2
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column ">
|
||||
<v-row class="flex-grow-0">
|
||||
<v-col class="bg-blue">
|
||||
2
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
<v-col class="d-flex flex-column ">
|
||||
<v-row>
|
||||
<v-col
|
||||
lg=9>
|
||||
|
||||
{{ countvis() }}
|
||||
|
||||
<div v-for="(val, key) in countgrupp()" :key = key>
|
||||
{{key}} : {{ val.now }} {{ val.week }} {{ val.year }}
|
||||
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col class="bg-black">
|
||||
5
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import { ref, computed } from 'vue'
|
||||
import {getfromserver, pagecounter} from '@/utils/universal_functions'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
setup(){
|
||||
|
||||
const visiting = ref({})
|
||||
const visiting = ref([])
|
||||
|
||||
getfromserver(`api/watcher/counter/`, visiting)
|
||||
pagecounter()
|
||||
|
||||
const countvis = () => {
|
||||
let start = '2023-01-21'
|
||||
let end = '2023-12-31'
|
||||
let filteres = visiting.value.filter(e => e.visitdate >= start && e.visitdate <= end)
|
||||
|
||||
|
||||
// let countAll = visiting.value.reduce((total, current)=> total +current.value, 0)
|
||||
console.log(filteres, '----dsds-----');
|
||||
|
||||
return filteres.reduce((total, current) => total + current.count, 0)
|
||||
}
|
||||
|
||||
const countgrupp = () => {
|
||||
|
||||
const maxDate = new Date(
|
||||
Math.max(
|
||||
...visiting.value.map(element => {
|
||||
return new Date(element.visitdate);
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
getfromserver(`api/watcher/counter/`, visiting)
|
||||
pagecounter()
|
||||
|
||||
return {
|
||||
visiting
|
||||
}
|
||||
|
||||
const groupedData =
|
||||
visiting.value.reduce((acc, item) => {
|
||||
|
||||
|
||||
if (!acc[item.pages]) {
|
||||
acc[item.pages] = {now: 0, week: 0, year: 0}
|
||||
}
|
||||
|
||||
acc[item.pages]['year'] += item.count
|
||||
|
||||
if (item.visitdate == moment(maxDate).format('YYYY-MM-DD')) {
|
||||
acc[item.pages]['now'] += item.count
|
||||
}
|
||||
|
||||
// acc[comment.pages].push(comment.count);
|
||||
// return acc;
|
||||
// }
|
||||
// return { ...acc, [comment.pages]: [comment.count] };
|
||||
return acc
|
||||
}, {});
|
||||
// filteres.reduce((acc, item) => {
|
||||
|
||||
// if (!acc[item.pages]) {
|
||||
// acc[item.pages] = 0
|
||||
// }
|
||||
// console.log(item.count, item.pages, 'item.count');
|
||||
// acc[item.pages] += item.count
|
||||
|
||||
|
||||
// return acc
|
||||
// }, {})
|
||||
|
||||
|
||||
|
||||
return groupedData
|
||||
}
|
||||
|
||||
return {
|
||||
visiting,
|
||||
countvis,
|
||||
countgrupp
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user