Статистика
This commit is contained in:
1 parent
ba502e0258
commit
e8a839854e
4 files changed
+69
-93
No files matched your search
@@ -7,7 +7,6 @@
|
||||
:total="total"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="h-100">
|
||||
<v-card class="pa-3 pt-4 pl-7 h-100">
|
||||
<star-like
|
||||
@@ -16,14 +15,12 @@
|
||||
/>
|
||||
</v-card>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<card-total
|
||||
name="Всего оставлено комментариев"
|
||||
:total="crit.total"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<top-user
|
||||
name= "Самый активный критик"
|
||||
@@ -31,7 +28,6 @@
|
||||
ico="mdi-comment-account-outline"
|
||||
/>
|
||||
</div>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
@@ -63,71 +59,59 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
setup(props, context) {
|
||||
const total = ref(0)
|
||||
const crit = ref({count: 0, fio: 0, total: 0})
|
||||
const crit = ref({count:0, login: 0, fio: '', post: '', info: [], total: 0})
|
||||
|
||||
|
||||
const average = () => {
|
||||
|
||||
let tot = new Set()
|
||||
let us = {}
|
||||
let t = 0
|
||||
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, post: ''}
|
||||
}
|
||||
if (item.comment.length > 0) {
|
||||
// console.log(us, item.comment, 'item.comment');
|
||||
us[splitname(item.author)]['count'].add(item.comment)
|
||||
us[splitname(item.author)]['login'] = item.author.login
|
||||
us[splitname(item.author)]['post'] = item.author.post
|
||||
const avgfeed =
|
||||
props.feedback
|
||||
.reduce((acc, item) => {
|
||||
|
||||
}
|
||||
|
||||
return acc
|
||||
}, {}
|
||||
)
|
||||
|
||||
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)] = {login: 0, fio: '', post: '', info: new Set()}
|
||||
}
|
||||
if (item.comment.length > 0) {
|
||||
us[splitname(item.author)]['fio']= splitname(item.author)
|
||||
us[splitname(item.author)]['info'].add(item.comment)
|
||||
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)
|
||||
}, 0)/val.rating.length).toFixed(1)
|
||||
}
|
||||
|
||||
|
||||
for (let [key,val] of Object.entries(us))
|
||||
for (let val of Object.values(us))
|
||||
{
|
||||
|
||||
t += val.count.size
|
||||
|
||||
|
||||
|
||||
if (crit.value.count < val.count.size) {
|
||||
crit.value = {fio:key,count:val.count, login: val.login, post: val.post}
|
||||
t += val.info.size
|
||||
|
||||
if (crit.value.count < val.info.size) {
|
||||
crit.value = {
|
||||
count: val.info.size, login: val.login, fio: val.fio, post: val.post, info: val.info, total: val.info.size
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -135,23 +119,13 @@ export default {
|
||||
crit.value.total = t
|
||||
total.value = tot.size
|
||||
|
||||
|
||||
|
||||
return avgfeed
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
average,
|
||||
total,
|
||||
crit
|
||||
|
||||
crit
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<script>
|
||||
import lineGraph from '@/components/graph/line-graph.vue'
|
||||
import {computed } from 'vue'
|
||||
import {format1} from '@/utils/universal_functions'
|
||||
import {format1, splitname} from '@/utils/universal_functions'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
setup(props, {emit}) {
|
||||
|
||||
const arrlines = {}
|
||||
const customLabel = ['c1', 'c2']
|
||||
// const customLabel = []
|
||||
|
||||
const data = computed({
|
||||
get() {
|
||||
@@ -36,7 +36,8 @@ export default {
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: [],
|
||||
hidden: true
|
||||
hidden: true,
|
||||
tooltips: false
|
||||
|
||||
},
|
||||
{
|
||||
@@ -45,7 +46,9 @@ export default {
|
||||
borderColor: 'teal',
|
||||
borderWidth: 3,
|
||||
cubicInterpolationMode: 'monotone',
|
||||
data: []
|
||||
data: [],
|
||||
customlabel: [],
|
||||
tooltips: true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -55,7 +58,6 @@ export default {
|
||||
})
|
||||
|
||||
const options = {
|
||||
|
||||
plugins: {
|
||||
datalabels: {
|
||||
color: 'grey',
|
||||
@@ -68,13 +70,19 @@ export default {
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
displayColors: false,
|
||||
callbacks: {
|
||||
// label: []
|
||||
label: function(tooltipItem, data) {
|
||||
// let label = []
|
||||
return customLabel.value[tooltipItem.index]
|
||||
label: function(context) {
|
||||
let label = context.dataset.label || '';
|
||||
if (context.datasetIndex==1) {
|
||||
if (context.parsed.y !== null) {
|
||||
label =arrlines.value.datasets[1].customlabel[context.dataIndex];
|
||||
}
|
||||
return label
|
||||
}
|
||||
}
|
||||
}}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
scales: {
|
||||
@@ -106,9 +114,9 @@ export default {
|
||||
acc[item.visitdate] = {unic: [], count: 0}
|
||||
}
|
||||
acc[item.visitdate]['count'] += item.count
|
||||
if (!acc[item.visitdate]['unic'].includes(item.author.id))
|
||||
if (!acc[item.visitdate]['unic'].includes(splitname(item.author)))
|
||||
{
|
||||
acc[item.visitdate]['unic'].push(item.author.id)
|
||||
acc[item.visitdate]['unic'].push(splitname(item.author))
|
||||
|
||||
}
|
||||
return acc
|
||||
@@ -116,20 +124,12 @@ export default {
|
||||
|
||||
Object.entries(datas).forEach(e => {
|
||||
const [key, value] = e
|
||||
console.log(key, value)
|
||||
arrlines.value.datasets[0].data.push(datas[key].count)
|
||||
arrlines.value.datasets[1].data.push(datas[key]['unic'].length)
|
||||
arrlines.value.labels.push(format1(key))
|
||||
// customLabel.value.push('datas[key].count')
|
||||
});
|
||||
arrlines.value.datasets[1].customlabel.push(datas[key].unic)
|
||||
})
|
||||
|
||||
// for (let [val, key] in datas) {
|
||||
// console.log(val, key, 'kkkkkkkkkkkk');
|
||||
// arrlines.value.datasets[0].data.push(datas[key].count)
|
||||
// arrlines.value.datasets[1].data.push(datas[key]['unic'].length)
|
||||
// arrlines.value.labels.push(format1(key))
|
||||
|
||||
// }
|
||||
}
|
||||
return {
|
||||
data,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
>
|
||||
<v-card-text class="text-h5 pa-2 pl-5 flex-wrap align-center d-flex justify-space-between">
|
||||
{{name}}
|
||||
<!-- <my-helper :pretext="users.count"/> -->
|
||||
<!-- <my-helper :pretext="users"/> -->
|
||||
<v-icon
|
||||
color="blue-grey-lighten-1"
|
||||
:icon="ico"
|
||||
@@ -20,13 +20,13 @@
|
||||
<v-col class="pt-8 text-center">
|
||||
|
||||
<span class="subheading text-h6">
|
||||
{{users.count.size}}
|
||||
{{users.count}}
|
||||
<v-tooltip
|
||||
v-if="name=='Активность'"
|
||||
activator="parent"
|
||||
location="top"
|
||||
>
|
||||
<div v-for="x in users.count" :key=x>
|
||||
<div v-for="x in users.info" :key=x>
|
||||
{{x}}
|
||||
</div>
|
||||
</v-tooltip>
|
||||
|
||||
@@ -353,12 +353,14 @@ setup(){
|
||||
|
||||
|
||||
if (!acc[splitname(item.author)]) {
|
||||
acc[splitname(item.author)] = {count: new Set(), login: '', fio: '', post: ''}
|
||||
acc[splitname(item.author)] = {count: 0, login: '', fio: '', post: '', info: new Set()}
|
||||
}
|
||||
|
||||
acc[splitname(item.author)]['fio'] = splitname(item.author)
|
||||
acc[splitname(item.author)]['count'].add(item.pages)
|
||||
acc[splitname(item.author)]['info'].add(item.pages)
|
||||
acc[splitname(item.author)]['login'] = item.author.login
|
||||
acc[splitname(item.author)]['post'] = item.author.post
|
||||
acc[splitname(item.author)]['count'] += item.count
|
||||
|
||||
|
||||
// }
|
||||
@@ -372,7 +374,7 @@ setup(){
|
||||
// const sorted = groupedData
|
||||
|
||||
const sorted = Object.entries(groupedData)
|
||||
.sort(([,a],[,b]) => (b.count.size - a.count.size))
|
||||
.sort(([,a],[,b]) => (b.count - a.count))
|
||||
.reduce((r, [k, v]) =>
|
||||
({ ...r, [k]: v } ), {}
|
||||
|
||||
|
||||
Reference in new issue
Block a user