164 lines
4.1 KiB
Vue
164 lines
4.1 KiB
Vue
<template>
|
|
<v-row>
|
|
<v-col class="d-flex flex-column">
|
|
<div>
|
|
<card-total
|
|
name="Всего поставлено оценок"
|
|
:total="total"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<v-card class="pa-3">
|
|
<star-like
|
|
:criteria=average()
|
|
:rating=average()
|
|
/>
|
|
</v-card>
|
|
</div>
|
|
|
|
<div>
|
|
<card-total
|
|
name="Всего оставлено комментариев"
|
|
:total="crit.total"
|
|
/>
|
|
</div>
|
|
|
|
<div>
|
|
<top-user
|
|
name= "Самый активный критик"
|
|
:users=crit
|
|
ico="mdi-comment-account-outline"
|
|
/>
|
|
</div>
|
|
|
|
</v-col>
|
|
</v-row>
|
|
</template>
|
|
|
|
<script>
|
|
import { ref } from 'vue'
|
|
import {splitname} from '@/utils/universal_functions'
|
|
import starLike from '@/components/UI/feedback/star-like.vue'
|
|
import CardTotal from '@/components/UI/aboutportal/card-total.vue'
|
|
import TopUser from '@/components/UI/aboutportal/top-user.vue'
|
|
|
|
export default {
|
|
|
|
components: {
|
|
starLike,
|
|
CardTotal,
|
|
TopUser
|
|
},
|
|
|
|
props: {
|
|
feedback: {
|
|
type: Array,
|
|
default: () => []
|
|
},
|
|
|
|
name: {
|
|
type: String,
|
|
default: ''
|
|
}
|
|
},
|
|
|
|
|
|
|
|
setup(props, context) {
|
|
const total = ref(0)
|
|
const crit = ref({count: 0, fio: 0, total: 0})
|
|
|
|
|
|
const average = () => {
|
|
|
|
let tot = new Set()
|
|
let us = {}
|
|
let t = 0
|
|
|
|
const avgfeed =
|
|
props.feedback
|
|
.reduce((acc, item) => {
|
|
|
|
if (!acc[item.namecrit]) {
|
|
acc[item.namecrit] = {rating: [], ico: '', color: '', name: ''}
|
|
}
|
|
|
|
|
|
acc[item.namecrit]['rating'].push(item.rating)
|
|
acc[item.namecrit]['ico'] = item.ico
|
|
acc[item.namecrit]['color'] = item.color
|
|
acc[item.namecrit]['name'] = item.namecrit
|
|
|
|
|
|
tot.add(item.usercom)
|
|
|
|
if (!us[splitname(item.author)]) {
|
|
us[splitname(item.author)] = {count: new Set(), login: 0}
|
|
}
|
|
if (item.comment.length > 0) {
|
|
us[splitname(item.author)]['count'].add(item.usercom)
|
|
us[splitname(item.author)]['login'] = item.author.login
|
|
us[splitname(item.author)]['post'] = item.author.post
|
|
|
|
}
|
|
|
|
return acc
|
|
}, {}
|
|
)
|
|
|
|
|
|
for (let [key,val] of Object.entries(avgfeed))
|
|
{
|
|
|
|
avgfeed[key]['rating'] = (val.rating.reduce((a,b)=>{
|
|
return a+b
|
|
}, 0
|
|
)/val.rating.length).toFixed(1)
|
|
}
|
|
|
|
|
|
for (let [key,val] of Object.entries(us))
|
|
{
|
|
|
|
t += val.count.size
|
|
|
|
|
|
|
|
if (crit.value.count < val.count.size) {
|
|
crit.value = {fio:key,count:val.count.size, login: val.login, post: val.post}
|
|
}
|
|
|
|
}
|
|
|
|
crit.value.total = t
|
|
total.value = tot.size
|
|
|
|
|
|
|
|
return avgfeed
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
average,
|
|
total,
|
|
crit
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style> |