From e424df11397e28910bd92a3ffd754b086e4e1a67 Mon Sep 17 00:00:00 2001 From: 0xdevant <0xdevant@gmail.com> Date: Mon, 22 Jul 2024 14:37:20 +0800 Subject: [PATCH] feat: enable scoring model on Project by certain data points --- components/Project/ProjectHeading.vue | 79 +++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 10 deletions(-) diff --git a/components/Project/ProjectHeading.vue b/components/Project/ProjectHeading.vue index 1098ea8..1e438d0 100644 --- a/components/Project/ProjectHeading.vue +++ b/components/Project/ProjectHeading.vue @@ -13,16 +13,76 @@ const availableSupport = computed(() => { return 0 }) + +/** + * From data points + - product readiness + - docs (yes/no) + - github (yes/no) + - team: anon / public + - audit: yes / no + */ +const calculateScore = computed(() => { + const criterias: { value: string, key?: string }[] = [ + { value: 'product_readiness' }, + { value: "github", key: 'links' }, + { value: "docs", key: 'links' }, + { value: 'team' }, + { value: 'audits' } + ]; + + let matched = 0; + for (let i = 0; i < criterias.length; i++) { + let value; + if (criterias[i].key) { + if(props.project[criterias[i].key] === null || props.project[criterias[i].key] === undefined) continue; + value = props.project[criterias[i].key][criterias[i].value]; + // console.log(props.project[criterias[i].key] == null); + } else { + value = props.project[criterias[i].value]; + } + // console.log(value); + + if (fulfilled(value)) { + matched++; + // console.log('matched', matched); + } + } + + return 100 / criterias.length * matched; +}) + +function fulfilled(value: any): boolean { + const type = typeof value; + switch (type) { + case 'string': + if (value !== '') return true; + break; + case 'array': + if (value.length > 0) return true; + break; + case 'object': + if (Object.keys(value).length > 0) return true; + break; + + default: + return false; + break; + } +} + const logo = props.project?.logos?.at(0)?.url {{ project.links?.github ? 'YES' : 'NO' }} - + @@ -79,7 +137,8 @@ const logo = props.project?.logos?.at(0)?.url
- + {{ project.blockchain_features?.network }}