@@ -7,12 +7,10 @@ export default async function({login, q, imports, graphql, data, account, querie
7
7
return null
8
8
9
9
//Load inputs
10
- let { filter, repositories} = imports . metadata . plugins . notable . inputs ( { data, account, q} )
10
+ let { filter, repositories, from } = imports . metadata . plugins . notable . inputs ( { data, account, q} )
11
11
12
- //Initialization
13
- const organizations = new Map ( )
14
-
15
- //Iterate through contributed repositories from organizations
12
+ //Iterate through contributed repositories
13
+ const notable = new Map ( )
16
14
{
17
15
let cursor = null
18
16
let pushed = 0
@@ -21,16 +19,16 @@ export default async function({login, q, imports, graphql, data, account, querie
21
19
const { user :{ repositoriesContributedTo :{ edges} } } = await graphql ( queries . notable . contributions ( { login, after :cursor ? `after: "${ cursor } "` : "" , repositories :data . shared [ "repositories.batch" ] || 100 } ) )
22
20
cursor = edges ?. [ edges ?. length - 1 ] ?. cursor
23
21
edges
24
- . filter ( ( { node} ) => node . isInOrganization )
25
- . filter ( ( { node} ) => imports . ghfilter ( filter , { name :node . nameWithOwner , stars :node . stargazers . totalCount , watchers :node . watchers . totalCount , forks :node . forks . totalCount } ) )
26
- . map ( ( { node} ) => organizations . set ( repositories ? node . nameWithOwner : node . owner . login , node . owner . avatarUrl ) )
22
+ . filter ( ( { node} ) => ( { all : true , organization : node . isInOrganization , user : ! node . isInOrganization } [ from ] ) )
23
+ . filter ( ( { node} ) => imports . ghfilter ( filter , { name :node . nameWithOwner , user : node . owner . login , stars :node . stargazers . totalCount , watchers :node . watchers . totalCount , forks :node . forks . totalCount } ) )
24
+ . map ( ( { node} ) => notable . set ( ( repositories || ! node . isInOrganization ) ? node . nameWithOwner : node . owner . login , { organization : node . isInOrganization , avatarUrl : node . owner . avatarUrl } ) )
27
25
pushed = edges . length
28
26
} while ( ( pushed ) && ( cursor ) )
29
27
}
30
28
31
29
//Set contributions
32
- const contributions = ( await Promise . all ( [ ...organizations . entries ( ) ] . map ( async ( [ name , avatarUrl ] ) => ( { name, avatar :await imports . imgb64 ( avatarUrl ) } ) ) ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
33
- console . debug ( `metrics/compute/${ login } /plugins > notable > found contributions to ${ organizations . length } organizations ` )
30
+ const contributions = ( await Promise . all ( [ ...notable . entries ( ) ] . map ( async ( [ name , { avatarUrl, organization } ] ) => ( { name, avatar :await imports . imgb64 ( avatarUrl ) , organization } ) ) ) ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
31
+ console . debug ( `metrics/compute/${ login } /plugins > notable > found ${ contributions . length } notable contributions ` )
34
32
35
33
//Results
36
34
return { contributions}
0 commit comments