Самые активные пользователи
This commit is contained in:
1 parent
380fefce85
commit
04e6458376
3 files changed
+76
-26
No files matched your search
@@ -109,6 +109,7 @@
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import {splitname} from '@/utils/universal_functions'
|
||||
|
||||
const accountStore = useAccountStore()
|
||||
|
||||
@@ -132,9 +133,7 @@ export default {
|
||||
return `${doc.split(' ').slice(0, 50).join(' ')} ${t.length<50?'':'...'}`
|
||||
}
|
||||
|
||||
const splitname = (name) => {
|
||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
||||
}
|
||||
|
||||
|
||||
const toggleIncrementLike = (newss, scores) => {
|
||||
axiosApiInstance.post(`api/navigation/newscrossroad/`, {news: newss, scores: scores}).then(result => {
|
||||
|
||||
@@ -58,7 +58,9 @@ export function checkremote(filecheck){
|
||||
|
||||
export default str;
|
||||
|
||||
|
||||
export function splitname (name) {
|
||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
||||
}
|
||||
|
||||
export function pagecounter(){
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
>
|
||||
<v-row class="flex-grow-0">
|
||||
<v-col class="bg-orange">
|
||||
1
|
||||
{{ countvis() }}
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row>
|
||||
@@ -25,9 +25,10 @@
|
||||
<v-col class="d-flex flex-column ">
|
||||
<v-row>
|
||||
<v-col
|
||||
lg=9>
|
||||
lg=9
|
||||
>
|
||||
|
||||
{{ countvis() }}
|
||||
|
||||
|
||||
<div v-for="(val, key) in countgrupp()" :key = key>
|
||||
{{key}} : {{ val.now }} {{ val.week }} {{ val.year }}
|
||||
@@ -35,7 +36,11 @@
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col class="bg-black">
|
||||
5
|
||||
<div v-for="(val, key) in activuser()" :key = key>
|
||||
{{key}} : {{ val.count }} {{ val.login }}
|
||||
|
||||
</div>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
@@ -46,7 +51,7 @@
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue'
|
||||
import {getfromserver, pagecounter} from '@/utils/universal_functions'
|
||||
import {getfromserver, pagecounter, splitname} from '@/utils/universal_functions'
|
||||
import moment from 'moment'
|
||||
export default {
|
||||
setup(){
|
||||
@@ -70,7 +75,6 @@ setup(){
|
||||
|
||||
let filteres = visiting.value.reduce((acc, item) => {
|
||||
|
||||
|
||||
acc['year'] += item.count
|
||||
|
||||
if (item.visitdate == moment(maxDate.value).format('YYYY-MM-DD')) {
|
||||
@@ -84,9 +88,6 @@ setup(){
|
||||
|
||||
return acc
|
||||
}, {now: 0, week: 0, year: 0})
|
||||
|
||||
|
||||
// let countAll = visiting.value.reduce((total, current)=> total +current.value, 0)
|
||||
|
||||
|
||||
return filteres
|
||||
@@ -98,7 +99,6 @@ setup(){
|
||||
|
||||
const groupedData =
|
||||
visiting.value.reduce((acc, item) => {
|
||||
// console.log(acc, item, 'acc, itemacc, item');
|
||||
|
||||
if (!acc[item.pages]) {
|
||||
acc[item.pages] = {now: 0, week: 0, year: 0}
|
||||
@@ -117,27 +117,76 @@ setup(){
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
const activuser = () => {
|
||||
|
||||
const groupedData =
|
||||
visiting.value.reduce((acc, item) => {
|
||||
console.log(Object.keys(acc).length, 'item------------');
|
||||
|
||||
|
||||
if (Object.keys(acc).length <3) { // выводит 0, затем 1, затем 2
|
||||
|
||||
|
||||
|
||||
if (!acc[splitname(item.author)]) {
|
||||
acc[splitname(item.author)] = {count: 0, login: ''}
|
||||
}
|
||||
|
||||
acc[splitname(item.author)]['count'] += item.count
|
||||
acc[splitname(item.author)]['login'] = item.author.login
|
||||
|
||||
}
|
||||
|
||||
|
||||
return acc
|
||||
}, {});
|
||||
|
||||
console.log(groupedData, 'groupedData--------');
|
||||
|
||||
|
||||
|
||||
const sorted = Object.entries(groupedData)
|
||||
.sort(([,a],[,b]) => b.count-a.count)
|
||||
.reduce((r, [k, v]) =>
|
||||
|
||||
({ ...r, [k]: v } ), {}
|
||||
|
||||
)
|
||||
|
||||
// .reduce((acc, item) => ({
|
||||
|
||||
// ...acc, [item]: groupedData[item]
|
||||
// }), {})
|
||||
|
||||
|
||||
|
||||
// Object.values(groupedData).sort(function(a, b) {
|
||||
// console.log(a, b);
|
||||
// return parseFloat(a.splitname(item.author)) - parseFloat(b.splitname(item.author));
|
||||
// });
|
||||
// groupedData.sort(function(a, b) { console.log(a,b, 'groupedData')})
|
||||
// groupedData.sort((a, b) => parseFloat(b.price) - parseFloat(a.price));
|
||||
console.log(sorted, 'groupedDatsorteda');
|
||||
|
||||
// const sortedValues = Object.values(groupedData).sort((a,b)=>b[1]-a[1])
|
||||
// topUser.value = sortedValues.slice(0, 1)
|
||||
// console.log(topUser.value, 'groupedData');
|
||||
|
||||
return sorted
|
||||
}
|
||||
|
||||
return {
|
||||
visiting,
|
||||
countvis,
|
||||
countgrupp
|
||||
countgrupp,
|
||||
activuser
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user