From a373fcc11e2fb4e1f1a66078e5aade7a7ce22b4c Mon Sep 17 00:00:00 2001 From: Mickey Nasriachi Date: Mon, 21 Oct 2024 20:00:27 +0200 Subject: [PATCH] Update tickets.pl - added github stars and watchers --- bin/tickets.pl | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/bin/tickets.pl b/bin/tickets.pl index 4b9e51b..19df497 100644 --- a/bin/tickets.pl +++ b/bin/tickets.pl @@ -19,8 +19,6 @@ # setup my $rt_summary_url //= 'https://rt.cpan.org/Public/bugs-per-dist.tsv'; -my $gh_issues_url - //= 'https://api.github.com/repos/%s/%s/issues?per_page=100'; $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; @@ -162,31 +160,38 @@ () log_debug {"Retrieving issues from $user/$repo"}; - my $data - = $gh_graphql->query( _gh_graphql_query( $json, $user, $repo ) ); + my $dist_summary = $summary{ $r->{'distribution'} } ||= {}; + + my $vars = { + user => $user, + repo => $repo, + }; + my $gh_query = _gh_graphql_query( $user, $repo ); + my $data = $gh_graphql->query( $gh_query, $vars ); if ( my $error = $data->{errors} ) { for my $error (@$error) { my $log_message = sprintf "[%s] %s", $r->{distribution}, $error->{message}; if ( $error->{type} eq 'NOT_FOUND' ) { - delete $summary{ $r->{distribution} }{bugs}{github}; + delete $dist_summary->{'bugs'}{'github'}; + delete $dist_summary->{'repo'}{'github'}; log_info {$log_message}; } else { log_error {$log_message}; } - next RELEASE; + next RELEASE if @$error; } } - my $open = $data->{data}{repository}{openIssues}{totalCount} - + $data->{data}{repository}{openPullRequests}{totalCount}; + my $repo_data = $data->{data}{repository}; + my $open = $repo_data->{openIssues}{totalCount} + + $repo_data->{openPullRequests}{totalCount}; + my $closed = $repo_data->{closedIssues}{totalCount} + + $repo_data->{closedPullRequests}{totalCount}; - my $closed = $data->{data}{repository}{closedIssues}{totalCount} - + $data->{data}{repository}{closedPullRequests}{totalCount}; - - my $rec = { + $dist_summary->{'bugs'}{'github'} = { active => $open, open => $open, closed => $closed, @@ -194,11 +199,13 @@ () }; - $summary{ $r->{distribution} }{bugs}{github} = $rec; + $dist_summary->{'repo'}{'github'} = { + stars => $repo_data->{stargazerCount}, + watchers => $repo_data->{watchers}{totalCount}, + }; } log_info {"writing github data"}; - _bulk_update( \%summary ); } @@ -227,10 +234,10 @@ ($resources) return (); } -sub _gh_graphql_query ( $json, $user, $repo ) { - sprintf <encode($_), $user, $repo; -query { - repository(owner: %s, name: %s) { +sub _gh_graphql_query ( $user, $repo ) { + sprintf <