@@ -126,57 +126,72 @@ RELEASE: while ( my $release = $scroll->next ) {
126126 next unless $user ;
127127 log_debug {" Retrieving issues from $user /$repo " };
128128
129- my $data = $self -> github_graphql-> query(
130- sprintf <<'END_QUERY' , map $json -> encode($_ ), $user , $repo );
131- query {
132- repository(owner: %s, name: %s) {
133- openIssues: issues(states: OPEN) {
134- totalCount
135- }
136- closedIssues: issues(states: CLOSED) {
137- totalCount
138- }
139- openPullRequests: pullRequests(states: OPEN) {
140- totalCount
141- }
142- closedPullRequests: pullRequests(states: [CLOSED, MERGED]) {
143- totalCount
144- }
129+ my $dist_summary = $summary { $release -> {' distribution' } } ||= {};
130+
131+ my $vars = {
132+ user => $user ,
133+ repo => $repo ,
134+ };
135+ my $data = $self -> github_graphql-> query( <<'END_QUERY' , $vars );
136+ query($user:String!, $repo:String!) {
137+ repository(owner: $user, name: $repo) {
138+ openIssues: issues(states: OPEN) {
139+ totalCount
140+ }
141+ closedIssues: issues(states: CLOSED) {
142+ totalCount
143+ }
144+ openPullRequests: pullRequests(states: OPEN) {
145+ totalCount
146+ }
147+ closedPullRequests: pullRequests(states: [CLOSED, MERGED]) {
148+ totalCount
145149 }
150+ watchers: watchers {
151+ totalCount
152+ }
153+ stargazerCount: stargazerCount
146154 }
155+ }
147156END_QUERY
148157
149158 if ( my $error = $data -> {errors } ) {
150159 for my $error (@$error ) {
151160 my $log_message
152161 = " [$release ->{distribution}] $error ->{message}" ;
153162 if ( $error -> {type } eq ' NOT_FOUND' ) {
154- delete $summary { $release -> {' distribution ' } }{ ' bugs ' }
155- {' github' };
163+ delete $dist_summary -> {' bugs ' }{ ' github ' };
164+ delete $dist_summary -> { ' repo ' } {' github' };
156165 log_info {$log_message };
157166 }
158167 else {
159168 log_error {$log_message };
160169 }
170+ }
171+ if (@$error ) {
161172 next RELEASE;
162173 }
163174 }
164175
176+ my $repo_data = $data -> {data }{repository };
165177 my $open
166- = $data -> { data }{ repository } {openIssues }{totalCount }
167- + $data -> { data }{ repository } {openPullRequests }{totalCount };
178+ = $repo_data -> {openIssues }{totalCount }
179+ + $repo_data -> {openPullRequests }{totalCount };
168180 my $closed
169- = $data -> { data }{ repository } {closedIssues }{totalCount }
170- + $data -> { data }{ repository } {closedPullRequests }{totalCount };
181+ = $repo_data -> {closedIssues }{totalCount }
182+ + $repo_data -> {closedPullRequests }{totalCount };
171183
172- my $rec = {
184+ $dist_summary -> { ' bugs ' }{ ' github ' } = {
173185 active => $open ,
174186 open => $open ,
175187 closed => $closed ,
176188 source => $source ,
177189 };
178190
179- $summary { $release -> {' distribution' } }{' bugs' }{' github' } = $rec ;
191+ $dist_summary -> {' repo' }{' github' } = {
192+ stars => $repo_data -> {stargazerCount },
193+ watchers => $repo_data -> {watchers }{totalCount },
194+ };
180195 }
181196
182197 log_info {" writing github data" };
0 commit comments