1
+ // SPDX-FileCopyrightText: 2023 - 2025 Ewan Cahen (Netherlands eScience Center) <[email protected] >
2
+ // SPDX-FileCopyrightText: 2023 - 2025 Netherlands eScience Center
1
3
// SPDX-FileCopyrightText: 2023 Dusan Mijatovic (dv4all)
2
- // SPDX-FileCopyrightText: 2023 Ewan Cahen (Netherlands eScience Center) <[email protected] >
3
- // SPDX-FileCopyrightText: 2023 Netherlands eScience Center
4
4
// SPDX-FileCopyrightText: 2023 dv4all
5
5
//
6
6
// SPDX-License-Identifier: Apache-2.0
@@ -29,6 +29,7 @@ export type ProjectQualityProps = {
29
29
research_domain_cnt : number ,
30
30
impact_cnt : number ,
31
31
output_cnt : number ,
32
+ category_cnt : number ,
32
33
score : number
33
34
}
34
35
@@ -53,8 +54,9 @@ realLabels.set('keyword_cnt', {'label': 'Keywords', 'type': 'number'})
53
54
realLabels . set ( 'research_domain_cnt' , { 'label' : 'Research domains' , 'type' : 'number' } )
54
55
realLabels . set ( 'impact_cnt' , { 'label' : 'Impact' , 'type' : 'number' } )
55
56
realLabels . set ( 'output_cnt' , { 'label' : 'Output' , 'type' : 'number' } )
57
+ realLabels . set ( 'category_cnt' , { 'label' : 'Categories' , 'type' : 'number' } )
56
58
57
- async function fetchProjectQuality ( showAll : boolean , token :string ) {
59
+ async function fetchProjectQuality ( showAll : boolean , token :string ) : Promise < ProjectQualityProps [ ] > {
58
60
try {
59
61
const url = getBaseUrl ( ) + `/rpc/project_quality?show_all=${ showAll } `
60
62
const resp = await fetch ( url , {
@@ -64,8 +66,7 @@ async function fetchProjectQuality(showAll: boolean, token:string) {
64
66
} )
65
67
if ( resp . status === 200 ) {
66
68
const json :ProjectQualityProps [ ] = await resp . json ( )
67
- const data = handleData ( json )
68
- return data
69
+ return handleData ( json )
69
70
}
70
71
logger ( `fetchProjectQuality...${ resp . status } : ${ resp . statusText } ` )
71
72
return [ ]
@@ -75,20 +76,23 @@ async function fetchProjectQuality(showAll: boolean, token:string) {
75
76
}
76
77
}
77
78
78
- function handleData ( data : ProjectQualityProps [ ] ) {
79
+ function handleData ( data : ProjectQualityProps [ ] ) : ProjectQualityProps [ ] {
79
80
data . forEach ( element => {
80
81
element . score = calculateScore ( element )
81
82
} )
82
83
return data
83
84
}
84
85
85
- function calculateScore ( element :ProjectQualityProps ) {
86
+ function calculateScore ( element :ProjectQualityProps ) : number {
86
87
let score = 0
87
88
let kpiCount = 0
88
89
89
90
const keys = Object . keys ( element ) as ProjectQualityKeys [ ]
90
91
keys . forEach ( ( key ) => {
91
- if ( key === 'title' || key === 'slug' || key === 'score' ) return
92
+ if ( key === 'title' || key === 'slug' || key === 'score' ) {
93
+ return
94
+ }
95
+
92
96
const value = element [ key ]
93
97
if ( typeof value !== 'undefined' && ( value === true || ( Number . isInteger ( value ) && value as number > 0 ) || typeof value === 'string' ) ) {
94
98
score += 1
0 commit comments