@@ -11,14 +11,17 @@ const pagination = node('pageInfo')
11
11
. addChild ( node ( 'endCursor' ) )
12
12
. addChild ( node ( 'hasNextPage' ) )
13
13
14
+ const userInfo = node ( 'user' )
15
+ . addChild ( node ( 'login' ) )
16
+ . addChild ( node ( 'name' ) )
17
+ . addChild ( node ( 'url' ) )
18
+
14
19
const reactorQ = node ( 'reactions' , { first : 10 } )
15
20
. addChild ( pagination )
16
21
. addChild ( node ( 'nodes' )
22
+ . addChild ( node ( 'id' ) )
17
23
. addChild ( node ( 'createdAt' ) )
18
- . addChild ( node ( 'user' )
19
- . addChild ( node ( 'login' ) )
20
- . addChild ( node ( 'name' ) )
21
- . addChild ( node ( 'url' ) ) ) )
24
+ . addChild ( userInfo ) )
22
25
23
26
const authoredQ = node ( 'nodes' )
24
27
. addChild ( node ( 'id' ) )
@@ -29,6 +32,30 @@ const authoredQ = node('nodes')
29
32
. addChild ( node ( 'url' ) ) ) )
30
33
. addChild ( node ( 'createdAt' ) )
31
34
35
+ const commitAuthorQ = node ( 'author' ) . addChild ( userInfo )
36
+
37
+ const commitHistoryQ = node ( 'nodes' )
38
+ . addChild ( node ( 'id' ) )
39
+ . addChild ( commitAuthorQ )
40
+
41
+ const commitQ = ( before , after ) => {
42
+ const b = before . toISOString ( )
43
+ const a = after . toISOString ( )
44
+ return node ( 'nodes' )
45
+ . addChild ( node ( 'id' ) )
46
+ . addChild ( node ( 'target' )
47
+ . addChild ( node ( 'id' ) )
48
+ . addChild ( node ( '... on Commit' )
49
+ . addChild (
50
+ node ( 'history' , { first : 100 , since : a , until : b } )
51
+ . addChild ( pagination )
52
+ . addChild ( commitHistoryQ ) ) ) )
53
+ }
54
+
55
+ const refsQ = ( before , after ) => node ( 'refs' , { first : 100 , refPrefix : 'refs/heads/' } )
56
+ . addChild ( pagination )
57
+ . addChild ( commitQ ( before , after ) )
58
+
32
59
const authoredWithReactionsQ = authoredQ
33
60
. addChild ( reactorQ )
34
61
@@ -55,10 +82,11 @@ const commitCommentQ = node('commitComments', {first: 100})
55
82
. addChild ( authoredQ )
56
83
57
84
/** Returns a query to retrieve all contributors to a repo */
58
- const repository = ( repoName , ownerName ) =>
85
+ const repository = ( repoName , ownerName , before , after ) =>
59
86
node ( 'repository' , { name : repoName , owner : ownerName } )
60
87
. addChild ( node ( 'id' ) )
61
88
. addChild ( commitCommentQ )
89
+ . addChild ( refsQ ( before , after ) )
62
90
. addChild ( prsQ )
63
91
. addChild ( issuesQ )
64
92
@@ -68,15 +96,18 @@ const organization = name =>
68
96
. addChild ( node ( 'id' ) )
69
97
. addChild ( node ( 'repositories' , { first : 100 } , pagination )
70
98
. addChild ( node ( 'nodes' )
99
+ . addChild ( node ( 'id' ) )
71
100
. addChild ( node ( 'name' ) ) ) )
72
101
73
- const orgRepos = name =>
102
+ const orgRepos = ( name , before , after ) =>
74
103
node ( 'organization' , { login : name } )
75
104
. addChild ( node ( 'id' ) )
76
105
. addChild ( node ( 'repositories' , { first : 25 } )
77
106
. addChild ( pagination )
78
107
. addChild ( node ( 'nodes' )
79
108
. addChild ( node ( 'id' ) )
109
+ . addChild ( commitCommentQ )
110
+ . addChild ( refsQ ( before , after ) )
80
111
. addChild ( prsQ )
81
112
. addChild ( issuesQ ) ) )
82
113
@@ -126,7 +157,7 @@ const fetchAll = async ({token, acc, data, type, key, count, query}) => {
126
157
* returns an array containing only those objects created between before and
127
158
* after.
128
159
*/
129
- const timeFilter = ( before = new Date ( ) , after = new Date ( 0 ) ) =>
160
+ const timeFilter = ( before , after ) =>
130
161
data => data . filter ( x => {
131
162
const date = new Date ( x . createdAt )
132
163
return after <= date && date <= before
@@ -199,6 +230,28 @@ const cleanRepo = async (token, result, before, after) => {
199
230
const tf = timeFilter ( before , after )
200
231
const process = x => mergeContributions ( users ( tf ( x ) ) )
201
232
233
+ const branches = await fetchAll ( {
234
+ token,
235
+ acc : result . refs . nodes ,
236
+ data : result ,
237
+ type : 'Repository' ,
238
+ key : 'refs' ,
239
+ count : 100 ,
240
+ query : commitQ ( before , after )
241
+ } )
242
+
243
+ const targets = Array . from ( branches ) . map ( b => b . target )
244
+
245
+ const commits = await depaginateAll ( targets , {
246
+ token,
247
+ acc : ref => ref . history . nodes ,
248
+ type : 'Commit' ,
249
+ key : 'history' ,
250
+ query : commitHistoryQ
251
+ } )
252
+
253
+ const commitAuthors = Array . from ( commits ) . map ( x => x . author )
254
+
202
255
const prs = await fetchAll ( {
203
256
token,
204
257
acc : result . pullRequests . nodes ,
@@ -286,6 +339,7 @@ const cleanRepo = async (token, result, before, after) => {
286
339
} ) )
287
340
288
341
return {
342
+ commitAuthors : mergeContributions ( users ( commitAuthors ) ) ,
289
343
commitCommentators : process ( commitComments ) ,
290
344
prCreators : process ( prs ) ,
291
345
prCommentators : process ( prComments ) ,
0 commit comments