mirror of
https://github.com/web3privacy/explorer-app.git
synced 2024-10-15 16:46:26 +02:00
fix(rating): show percentage in rating instead of total points
This commit is contained in:
parent
d06cf7ee2d
commit
ad5a944f1b
6 changed files with 24 additions and 16 deletions
|
@ -165,7 +165,7 @@ const projectItems: { label: string | string[], type: string, rating?: ProjectRa
|
||||||
</div>
|
</div>
|
||||||
<ProjectRating
|
<ProjectRating
|
||||||
v-if="projectItem.type! === 'rating' && projectItem.rating"
|
v-if="projectItem.type! === 'rating' && projectItem.rating"
|
||||||
:percentage="projectItem.rating.points"
|
:percentage="projectItem.rating.percentagePoints"
|
||||||
:rating="projectItem.rating"
|
:rating="projectItem.rating"
|
||||||
:type="projectItem.rating.type"
|
:type="projectItem.rating.type"
|
||||||
/>
|
/>
|
||||||
|
@ -210,7 +210,7 @@ const projectItems: { label: string | string[], type: string, rating?: ProjectRa
|
||||||
</div>
|
</div>
|
||||||
<ProjectRating
|
<ProjectRating
|
||||||
v-if="(filter.sortby === 'openess' || filter.sortby === 'technology' || filter.sortby === 'privacy') && project.ratings?.find((r) => r.type === filter.sortby) && !isLargeScreen"
|
v-if="(filter.sortby === 'openess' || filter.sortby === 'technology' || filter.sortby === 'privacy') && project.ratings?.find((r) => r.type === filter.sortby) && !isLargeScreen"
|
||||||
:percentage="project.ratings.find((r) => r.type === filter.sortby)!.points"
|
:percentage="project.ratings.find((r) => r.type === filter.sortby)!.percentagePoints"
|
||||||
:rating="project.ratings.find((r) => r.type === filter.sortby)!"
|
:rating="project.ratings.find((r) => r.type === filter.sortby)!"
|
||||||
compact
|
compact
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -215,7 +215,7 @@ const logo = props.project?.logos?.at(0)?.url
|
||||||
</p>
|
</p>
|
||||||
<ProjectRating
|
<ProjectRating
|
||||||
:rating="rating"
|
:rating="rating"
|
||||||
:percentage="rating.points"
|
:percentage="rating.percentagePoints"
|
||||||
:disable-popover="!isLargeScreen"
|
:disable-popover="!isLargeScreen"
|
||||||
compact
|
compact
|
||||||
:selected="rating.type === selectedMobileRating?.type && !isLargeScreen"
|
:selected="rating.type === selectedMobileRating?.type && !isLargeScreen"
|
||||||
|
@ -267,7 +267,7 @@ const logo = props.project?.logos?.at(0)?.url
|
||||||
>
|
>
|
||||||
<ProjectRating
|
<ProjectRating
|
||||||
:rating="selectedMobileRating"
|
:rating="selectedMobileRating"
|
||||||
:percentage="selectedMobileRating.points"
|
:percentage="selectedMobileRating.percentagePoints"
|
||||||
:disable-popover="!isLargeScreen"
|
:disable-popover="!isLargeScreen"
|
||||||
compact
|
compact
|
||||||
show-only-popover
|
show-only-popover
|
||||||
|
|
|
@ -64,7 +64,7 @@ defineProps<{
|
||||||
bold
|
bold
|
||||||
title="Compliance with"
|
title="Compliance with"
|
||||||
>
|
>
|
||||||
{{ project.compliance ? 'YES' : 'NO' }}
|
{{ project.compliance ? project.compliance : 'NO' }}
|
||||||
</ProjectInfoItem>
|
</ProjectInfoItem>
|
||||||
<ProjectInfoItem
|
<ProjectInfoItem
|
||||||
:check-undefined="project.tracebility?.sign_in_type_requirments"
|
:check-undefined="project.tracebility?.sign_in_type_requirments"
|
||||||
|
|
|
@ -14,16 +14,16 @@ const props = defineProps<{
|
||||||
const emits = defineEmits(['selected'])
|
const emits = defineEmits(['selected'])
|
||||||
|
|
||||||
const colors = [
|
const colors = [
|
||||||
'#ff0000', // 0-10%
|
'#EA171D', // 0-10%
|
||||||
'#ff4500', // 11-20%
|
'#FB2D00', // 11-20%
|
||||||
'#ff8c00', // 21-30%
|
'#FD6515', // 21-30%
|
||||||
'#ffd700', // 31-40%
|
'#FD941A', // 31-40%
|
||||||
'#adff2f', // 41-50%
|
'#FECD0A', // 41-50%
|
||||||
'#7fff00', // 51-60%
|
'#FFD806', // 51-60%
|
||||||
'#00ff00', // 61-70%
|
'#D2EF1F', // 61-70%
|
||||||
'#32cd32', // 71-80%
|
'#95DF1C', // 71-80%
|
||||||
'#00fa9a', // 81-90%
|
'#42FF00', // 81-90%
|
||||||
'#00ffff', // 91-100%
|
'#42FF00', // 91-100%
|
||||||
]
|
]
|
||||||
|
|
||||||
const backgroundColorByScore = computed(() => {
|
const backgroundColorByScore = computed(() => {
|
||||||
|
|
|
@ -233,6 +233,7 @@ export const useData = defineStore('data', () => {
|
||||||
const generateProjectRating = (project: Project) => {
|
const generateProjectRating = (project: Project) => {
|
||||||
const projectRatings: ProjectRating[] = ranks.value?.map((rank) => {
|
const projectRatings: ProjectRating[] = ranks.value?.map((rank) => {
|
||||||
let rankPoints = 0
|
let rankPoints = 0
|
||||||
|
let maxPoints = 0
|
||||||
|
|
||||||
const ratingStats: ProjectRatingItem[] = rank.references?.map((ref) => {
|
const ratingStats: ProjectRatingItem[] = rank.references?.map((ref) => {
|
||||||
let isValid = false
|
let isValid = false
|
||||||
|
@ -240,6 +241,7 @@ export const useData = defineStore('data', () => {
|
||||||
|
|
||||||
let value
|
let value
|
||||||
let positive
|
let positive
|
||||||
|
let negative
|
||||||
|
|
||||||
if (ref.condition.minLength !== undefined) {
|
if (ref.condition.minLength !== undefined) {
|
||||||
value = (field as any[])?.length
|
value = (field as any[])?.length
|
||||||
|
@ -252,6 +254,9 @@ export const useData = defineStore('data', () => {
|
||||||
value = field
|
value = field
|
||||||
if (value !== undefined)
|
if (value !== undefined)
|
||||||
isValid = value === ref.condition.equals
|
isValid = value === ref.condition.equals
|
||||||
|
if (ref.field === 'compliance') {
|
||||||
|
negative = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ref.condition.exists !== undefined) {
|
if (ref.condition.exists !== undefined) {
|
||||||
|
@ -260,11 +265,12 @@ export const useData = defineStore('data', () => {
|
||||||
isValid = !!value
|
isValid = !!value
|
||||||
}
|
}
|
||||||
rankPoints += isValid ? ref.points : 0
|
rankPoints += isValid ? ref.points : 0
|
||||||
|
maxPoints += ref.points
|
||||||
return {
|
return {
|
||||||
isValid,
|
isValid,
|
||||||
label: ref.label.name,
|
label: ref.label.name,
|
||||||
positive: positive ? positive : ref.label.positive,
|
positive: positive ? positive : ref.label.positive,
|
||||||
negative: ref.label.negative,
|
negative: negative ? negative : ref.label.negative,
|
||||||
value,
|
value,
|
||||||
} as ProjectRatingItem
|
} as ProjectRatingItem
|
||||||
})
|
})
|
||||||
|
@ -273,6 +279,7 @@ export const useData = defineStore('data', () => {
|
||||||
name: rank.name,
|
name: rank.name,
|
||||||
items: ratingStats,
|
items: ratingStats,
|
||||||
points: rankPoints,
|
points: rankPoints,
|
||||||
|
percentagePoints: rankPoints / maxPoints * 100,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ export interface ProjectRating {
|
||||||
name: string
|
name: string
|
||||||
items: ProjectRatingItem[]
|
items: ProjectRatingItem[]
|
||||||
points: number
|
points: number
|
||||||
|
percentagePoints: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProjectRatingItem {
|
export interface ProjectRatingItem {
|
||||||
|
|
Loading…
Reference in a new issue