19
19
20
20
# setup
21
21
my $rt_summary_url //= ' https://rt.cpan.org/Public/bugs-per-dist.tsv' ;
22
- my $gh_issues_url
23
- / /= 'https://api.github.com/repos/%s /%s /issues?per_page=100';
24
22
25
23
$ENV {PERL_LWP_SSL_VERIFY_HOSTNAME } = 0;
26
24
162
160
163
161
log_debug {" Retrieving issues from $user /$repo " };
164
162
165
- my $data
166
- = $gh_graphql -> query( _gh_graphql_query( $json , $user , $repo ) );
163
+ my $dist_summary = $summary { $r -> {' distribution' } } ||= {};
164
+
165
+ my $vars = {
166
+ user => $user ,
167
+ repo => $repo ,
168
+ };
169
+ my $gh_query = _gh_graphql_query( $user , $repo );
170
+ my $data = $gh_graphql -> query( $gh_query , $vars );
167
171
168
172
if ( my $error = $data -> {errors } ) {
169
173
for my $error (@$error ) {
170
174
my $log_message = sprintf " [%s ] %s " , $r -> {distribution },
171
175
$error -> {message };
172
176
if ( $error -> {type } eq ' NOT_FOUND' ) {
173
- delete $summary { $r -> {distribution } }{bugs }{github };
177
+ delete $dist_summary -> {' bugs' }{' github' };
178
+ delete $dist_summary -> {' repo' }{' github' };
174
179
log_info {$log_message };
175
180
}
176
181
else {
177
182
log_error {$log_message };
178
183
}
179
- next RELEASE;
184
+ next RELEASE if @$error ;
180
185
}
181
186
}
182
187
183
- my $open = $data -> {data }{repository }{openIssues }{totalCount }
184
- + $data -> {data }{repository }{openPullRequests }{totalCount };
188
+ my $repo_data = $data -> {data }{repository };
189
+ my $open = $repo_data -> {openIssues }{totalCount }
190
+ + $repo_data -> {openPullRequests }{totalCount };
191
+ my $closed = $repo_data -> {closedIssues }{totalCount }
192
+ + $repo_data -> {closedPullRequests }{totalCount };
185
193
186
- my $closed = $data -> {data }{repository }{closedIssues }{totalCount }
187
- + $data -> {data }{repository }{closedPullRequests }{totalCount };
188
-
189
- my $rec = {
194
+ $dist_summary -> {' bugs' }{' github' } = {
190
195
active => $open ,
191
196
open => $open ,
192
197
closed => $closed ,
193
198
source => $source ,
194
199
195
200
};
196
201
197
- $summary { $r -> {distribution } }{bugs }{github } = $rec ;
202
+ $dist_summary -> {' repo' }{' github' } = {
203
+ stars => $repo_data -> {stargazerCount },
204
+ watchers => $repo_data -> {watchers }{totalCount },
205
+ };
198
206
}
199
207
200
208
log_info {" writing github data" };
201
-
202
209
_bulk_update( \%summary );
203
210
}
204
211
@@ -227,10 +234,10 @@ ($resources)
227
234
return ();
228
235
}
229
236
230
- sub _gh_graphql_query ( $json , $ user , $repo ) {
231
- sprintf <<END_QUERY , map $json -> encode( $_ ), $user , $repo ;
232
- query {
233
- repository(owner: %s , name: %s ) {
237
+ sub _gh_graphql_query ( $user , $repo ) {
238
+ sprintf <<END_QUERY ;
239
+ query( $user :String!, $repo :String!) {
240
+ repository(owner: $user , name: $repo ) {
234
241
openIssues: issues(states: OPEN) {
235
242
totalCount
236
243
}
@@ -243,6 +250,10 @@ ( $json, $user, $repo )
243
250
closedPullRequests: pullRequests(states: [CLOSED, MERGED]) {
244
251
totalCount
245
252
}
253
+ watchers: watchers {
254
+ totalCount
255
+ }
256
+ stargazerCount: stargazerCount
246
257
}
247
258
}
248
259
END_QUERY
0 commit comments