@@ -12,7 +12,7 @@ import { runRemoteQuery } from './run-remote-query';
1212import { RemoteQueriesInterfaceManager } from './remote-queries-interface' ;
1313import { RemoteQuery } from './remote-query' ;
1414import { RemoteQueriesMonitor } from './remote-queries-monitor' ;
15- import { getRemoteQueryIndex } from './gh-actions-api-client' ;
15+ import { getRemoteQueryIndex , getStargazers } from './gh-actions-api-client' ;
1616import { RemoteQueryResultIndex } from './remote-query-result-index' ;
1717import { RemoteQueryResult } from './remote-query-result' ;
1818import { DownloadLink } from './download-link' ;
@@ -181,8 +181,12 @@ export class RemoteQueriesManager extends DisposableObject {
181181 results => this . interfaceManager . setAnalysisResults ( results , queryResult . queryId ) ) ;
182182 }
183183
184- private mapQueryResult ( executionEndTime : number , resultIndex : RemoteQueryResultIndex , queryId : string ) : RemoteQueryResult {
185-
184+ private mapQueryResult (
185+ executionEndTime : number ,
186+ resultIndex : RemoteQueryResultIndex ,
187+ queryId : string ,
188+ stargazers : Record < string , number >
189+ ) : RemoteQueryResult {
186190 const analysisSummaries = resultIndex . successes . map ( item => ( {
187191 nwo : item . nwo ,
188192 databaseSha : item . sha || 'HEAD' ,
@@ -193,6 +197,7 @@ export class RemoteQueriesManager extends DisposableObject {
193197 urlPath : `${ resultIndex . artifactsUrlPath } /${ item . artifactId } ` ,
194198 innerFilePath : item . sarifFileSize ? 'results.sarif' : 'results.bqrs' ,
195199 queryId,
200+ starCount : stargazers [ item . nwo ]
196201 } as DownloadLink
197202 } ) ) ;
198203 const analysisFailures = resultIndex . failures . map ( item => ( {
@@ -279,7 +284,8 @@ export class RemoteQueriesManager extends DisposableObject {
279284 queryItem . completed = true ;
280285 queryItem . status = QueryStatus . Completed ;
281286 queryItem . failureReason = undefined ;
282- const queryResult = this . mapQueryResult ( executionEndTime , resultIndex , queryItem . queryId ) ;
287+ const stargazers = await this . getStargazersCount ( resultIndex , credentials ) ;
288+ const queryResult = this . mapQueryResult ( executionEndTime , resultIndex , queryItem . queryId , stargazers ) ;
283289
284290 await this . storeJsonFile ( queryItem , 'query-result.json' , queryResult ) ;
285291
@@ -303,7 +309,12 @@ export class RemoteQueriesManager extends DisposableObject {
303309 }
304310 }
305311
306- // Pulled from the analysis results manager, so that we can get access to
312+ private async getStargazersCount ( resultIndex : RemoteQueryResultIndex , credentials : Credentials ) {
313+ const nwos = resultIndex . successes . map ( s => s . nwo ) ;
314+ return await getStargazers ( credentials , nwos ) ;
315+ }
316+
317+ // Pulled from the analysis results manager, so that we can get access to
307318 // analyses results from the "export results" command.
308319 public getAnalysesResults ( queryId : string ) : AnalysisResults [ ] {
309320 return [ ...this . analysesResultsManager . getAnalysesResults ( queryId ) ] ;
0 commit comments