From 8f701420a9bce91b3718d0194aa6a6dcc2c66637 Mon Sep 17 00:00:00 2001 From: iriska-gri <79623434+iriska-gri@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:57:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D1=80=D0=B0=D1=82=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D1=81=D0=B2=D1=8F=D0=B7=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/UI/aboutportal/feedmodul.vue | 57 ++++++++++--------- src/front/src/views/AboutPortalPage.vue | 4 +- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/front/src/components/UI/aboutportal/feedmodul.vue b/src/front/src/components/UI/aboutportal/feedmodul.vue index 0407ad12b..4c5eace00 100644 --- a/src/front/src/components/UI/aboutportal/feedmodul.vue +++ b/src/front/src/components/UI/aboutportal/feedmodul.vue @@ -7,7 +7,7 @@ {{val}} {{total}} - + {{crit}} @@ -26,51 +26,55 @@ export default { setup(props, context) { const total = ref(0) - - const crit = () => { - const basecrit = - props.feedback.reduce((acc, item) => { - if (!acc[item.usercom]) { - acc[item.usercom] = 0 - } - acc[item.usercom] += 1 - return acc - }, {} - ) - return basecrit - } - - + const crit = ref({max: 0, id: 0, total: 0}) + const average = () => { - console.log(props.feedback); + let tot = new Set() - + let us = {} + let t = 0 const avgfeed = - props.feedback .reduce((acc, item) => { if (!acc[item.crit]) { acc[item.crit] = [] } acc[item.crit].push(item.rating) - tot.add(item.usercom) - + + if (!us[item.author.id]) { + us[item.author.id] =new Set() + } + if (item.comment.length > 0) { + us[item.author.id].add(item.usercom) + } + + + return acc }, {} ) - + + for (let [key,val] of Object.entries(avgfeed)) { avgfeed[key] = (val.reduce((a,b)=>{ return a+b }, 0 )/val.length).toFixed(1) - } - - + + for (let [key,val] of Object.entries(us)) + { + t += val.size + + if (crit.value.max < val.size) { + crit.value = {id:key,max:val.size} + } + + } + crit.value.total = t total.value = tot.size return avgfeed @@ -84,7 +88,8 @@ export default { return { average, - total + total, + crit } diff --git a/src/front/src/views/AboutPortalPage.vue b/src/front/src/views/AboutPortalPage.vue index 878d9d76f..705bb8099 100644 --- a/src/front/src/views/AboutPortalPage.vue +++ b/src/front/src/views/AboutPortalPage.vue @@ -90,8 +90,8 @@