@@ -21,12 +21,16 @@ export const processWorks = (works) => {
21
21
data . sets [ field ] [ work . id ] = new Set ( ) ;
22
22
}
23
23
24
- data . works [ `work-${ work . id } ` ] = { count : work . cited_by_count , label : work . title } ;
24
+ let label = work . authorships . slice ( 0 , 3 ) . map ( ( authorship ) => authorship . author . display_name ) . join ( ', ' ) ;
25
+ if ( work . authorships . length > 3 ) {
26
+ label += ' et al.' ;
27
+ }
28
+ label += `, ${ work . publication_year } ` ;
29
+ data . works [ `work-${ work . id } ` ] = { count : work . cited_by_count , title : work . title , label} ;
25
30
data . sets . works [ work . id ] . add ( `work-${ work . id } ` ) ;
26
31
27
32
work . referenced_works . forEach ( ( ref ) => {
28
33
incOrCreate ( data . refs , ref , 'count' ) ;
29
- data . refs [ ref ] . label = ref ;
30
34
} ) ;
31
35
data . sets . refs [ work . id ] = new Set ( work . referenced_works ) ;
32
36
@@ -161,11 +165,17 @@ export const filterData = async (data, filters) => {
161
165
162
166
filteredData . maxCounts . refs = filteredRefs . reduce ( ( acc , [ , { count} ] ) => Math . max ( acc , count ) , 0 ) ;
163
167
164
- // Get the refs labels
168
+ // Create the refs labels
165
169
console . time ( 'label refs' ) ;
166
- const refsLabels = await fetchRefsLabels ( filteredRefs . map ( ( [ id , ] ) => id ) ) ;
167
- for ( const { id, display_name} of refsLabels ) {
168
- filteredData . refs [ id ] . label = display_name ;
170
+ const refsLabels = await fetchRefsLabels ( filteredRefs . map ( ( [ id , ] ) => id ) , 50 ) ;
171
+ for ( const { id, title, authorships, publication_year} of refsLabels ) {
172
+ let label = authorships . slice ( 0 , 3 ) . map ( ( authorship ) => authorship . author . display_name ) . join ( ', ' ) ;
173
+ if ( authorships . length > 3 ) {
174
+ label += ' et al.' ;
175
+ }
176
+ label += `, ${ publication_year } ` ;
177
+ filteredData . refs [ id ] . label = label ;
178
+ filteredData . refs [ id ] . title = title ;
169
179
}
170
180
console . timeEnd ( 'label refs' ) ;
171
181
0 commit comments