@@ -7,12 +7,13 @@ export default async function({login, q, imports, data, graphql, queries, accoun
77 return null
88
99 //Load inputs
10- let { limit, days, details, display, ignored} = imports . metadata . plugins . reactions . inputs ( { data, account, q} )
10+ let { limit : _limit1 , "limit.issues" : _limit2 , days, details, display, ignored} = imports . metadata . plugins . reactions . inputs ( { data, account, q} )
1111
1212 //Load issue comments
13- let cursor = null , pushed = 0
1413 const comments = [ ]
15- for ( const type of [ "issues" , "issueComments" ] ) {
14+ for ( const { type, limit} of [ { type :"issueComments" , limit :_limit1 } , { type :"issues" , limit :_limit2 } ] . filter ( ( { limit} ) => limit ) ) {
15+ let cursor = null , pushed = 0
16+ const fetched = [ ]
1617 do {
1718 //Load issue comments
1819 console . debug ( `metrics/compute/${ login } /plugins > reactions > retrieving ${ type } after ${ cursor } ` )
@@ -23,19 +24,17 @@ export default async function({login, q, imports, data, graphql, queries, accoun
2324 . flatMap ( ( { node :{ createdAt :created , reactions :{ nodes :reactions } } } ) => ( { created :new Date ( created ) , reactions :reactions . filter ( ( { user = { } } ) => ! ignored . includes ( user . login ) ) . map ( ( { content} ) => content ) } ) )
2425 . filter ( comment => Number . isFinite ( days ) ? comment . created < new Date ( Date . now ( ) - days * 24 * 60 * 60 * 1000 ) : true )
2526 pushed = filtered . length
26- comments . push ( ...filtered )
27- console . debug ( `metrics/compute/${ login } /plugins > reactions > currently at ${ comments . length } comments` )
28- //Early break
29- if ( ( comments . length >= limit ) || ( filtered . length < edges . length ) )
30- break
31- } while ( ( cursor ) && ( pushed ) && ( comments . length < limit ) )
32- }
33-
34- //Applying limit
35- if ( limit ) {
36- comments . splice ( limit )
37- console . debug ( `metrics/compute/${ login } /plugins > reactions > keeping only ${ comments . length } comments` )
27+ fetched . push ( ...filtered )
28+ console . debug ( `metrics/compute/${ login } /plugins > reactions > currently at ${ fetched . length } ${ type } comments` )
29+ //Applying limit
30+ if ( ( fetched . length >= limit ) || ( filtered . length < edges . length ) ) {
31+ fetched . splice ( limit )
32+ console . debug ( `metrics/compute/${ login } /plugins > reactions > keeping only ${ fetched . length } ${ type } comments` )
33+ }
34+ } while ( ( cursor ) && ( pushed ) && ( fetched . length < limit ) )
35+ comments . push ( ...fetched )
3836 }
37+ console . debug ( `metrics/compute/${ login } /plugins > reactions > fetched ${ comments . length } comments` )
3938
4039 //Format reactions list
4140 const list = { }
0 commit comments