From c8035c6ff91fdd1def571a975a6d052929ceb491 Mon Sep 17 00:00:00 2001 From: 0xdevant <0xdevant@gmail.com> Date: Thu, 27 Jun 2024 18:33:30 +0800 Subject: [PATCH 1/6] fix: update empty project link checking to fix search box input issue --- composables/useData.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/composables/useData.ts b/composables/useData.ts index 5a2442d..a2d6ad8 100644 --- a/composables/useData.ts +++ b/composables/useData.ts @@ -45,10 +45,11 @@ export const useData = defineStore('data', () => { const projectToShallow = (project: Project): ProjectShallow => { const availableSupport = () => { const filteredKeys = ['forum', 'discord', 'twitter', 'lens', 'farcaster', 'telegram'] - if (typeof project.links === 'object' && (project.links !== null || project.links !== undefined)) - return Object.keys(project.links).filter(key => filteredKeys.includes(key)).length + // if (typeof project.links === 'object' && (project.links !== null || project.links !== undefined)) + if (project.links == null || project.links == undefined) return 0; - return 0 + if (typeof project.links === 'object' && Object.keys(project.links).length > 0) + return Object.keys(project.links).filter(key => filteredKeys.includes(key)).length } return { @@ -96,8 +97,8 @@ export const useData = defineStore('data', () => { .filter((project) => { return ( project - && project.title1 - && project.title1.toLowerCase().includes(query) + && project.title1 + && project.title1.toLowerCase().includes(query) ) }).filter((project) => { if (filter.sortby === 'anonymity') From 26f613ec7cf51137e650ef7275537837c2a1a9dd Mon Sep 17 00:00:00 2001 From: 0xdevant <0xdevant@gmail.com> Date: Thu, 27 Jun 2024 19:00:42 +0800 Subject: [PATCH 2/6] fix: lint --- composables/useData.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composables/useData.ts b/composables/useData.ts index a2d6ad8..853fcd7 100644 --- a/composables/useData.ts +++ b/composables/useData.ts @@ -46,7 +46,8 @@ export const useData = defineStore('data', () => { const availableSupport = () => { const filteredKeys = ['forum', 'discord', 'twitter', 'lens', 'farcaster', 'telegram'] // if (typeof project.links === 'object' && (project.links !== null || project.links !== undefined)) - if (project.links == null || project.links == undefined) return 0; + if (project.links === null || project.links === undefined) + return 0 if (typeof project.links === 'object' && Object.keys(project.links).length > 0) return Object.keys(project.links).filter(key => filteredKeys.includes(key)).length 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 3/6] 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 }} From 950b4164a06599d47f12df92299cfb3bed87fb5a Mon Sep 17 00:00:00 2001 From: 0xdevant <0xdevant@gmail.com> Date: Mon, 22 Jul 2024 15:36:53 +0800 Subject: [PATCH 4/6] fix: account for null values --- components/Project/ProjectHeading.vue | 86 +++++++++++++++------------ 1 file changed, 48 insertions(+), 38 deletions(-) diff --git a/components/Project/ProjectHeading.vue b/components/Project/ProjectHeading.vue index 1e438d0..537fd74 100644 --- a/components/Project/ProjectHeading.vue +++ b/components/Project/ProjectHeading.vue @@ -13,7 +13,6 @@ const availableSupport = computed(() => { return 0 }) - /** * From data points - product readiness @@ -22,52 +21,53 @@ const availableSupport = computed(() => { - team: anon / public - audit: yes / no */ -const calculateScore = computed(() => { - const criterias: { value: string, key?: string }[] = [ +const calculateScore: number = computed(() => { + const criterias: { value: string; key?: string }[] = [ { value: 'product_readiness' }, - { value: "github", key: 'links' }, - { value: "docs", key: 'links' }, + { value: 'github', key: 'links' }, + { value: 'docs', key: 'links' }, { value: 'team' }, - { value: 'audits' } - ]; + { value: 'audits' }, + ] - let matched = 0; + let matched = 0 for (let i = 0; i < criterias.length; i++) { - let value; + 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]; + if (props.project[criterias[i].key] === null || props.project[criterias[i].key] === undefined) + continue + value = props.project[criterias[i].key][criterias[i].value] + } + else { + if (props.project[criterias[i].value] === null || props.project[criterias[i].value] === undefined) + continue + value = props.project[criterias[i].value] } // console.log(value); + // console.log(Object.keys(props.project["team"]).length); - if (fulfilled(value)) { - matched++; + if (fulfilled(value)) + matched++ // console.log('matched', matched); - } } - return 100 / criterias.length * matched; + return 100 / criterias.length * matched }) function fulfilled(value: any): boolean { - const type = typeof value; + const type = typeof value switch (type) { case 'string': - if (value !== '') return true; - break; - case 'array': - if (value.length > 0) return true; - break; + if (value !== '') + return true + break case 'object': - if (Object.keys(value).length > 0) return true; - break; + if (Object.keys(value).length > 0) + return true + break default: - return false; - break; + return false } } @@ -76,13 +76,17 @@ const logo = props.project?.logos?.at(0)?.url {{ project.links?.github ? 'YES' : 'NO' }} - + @@ -137,8 +145,10 @@ const logo = props.project?.logos?.at(0)?.url
- + {{ project.blockchain_features?.network }} From abc5e3cd4d85b8054f283dae3f0391b655c43aaa Mon Sep 17 00:00:00 2001 From: 0xdevant <0xdevant@gmail.com> Date: Mon, 22 Jul 2024 18:17:18 +0800 Subject: [PATCH 5/6] fix: optional return for null cases --- components/Project/ProjectHeading.vue | 39 +++++++++++++-------------- types/project.ts | 4 +++ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/components/Project/ProjectHeading.vue b/components/Project/ProjectHeading.vue index 537fd74..fd8cd3b 100644 --- a/components/Project/ProjectHeading.vue +++ b/components/Project/ProjectHeading.vue @@ -1,5 +1,5 @@