Статистика

This commit is contained in:
iriska-gri committed 2024-01-25 09:26:12 +03:00
1 parent ba502e0258
commit e8a839854e
4 files changed
+69 -93

No files matched your search

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