Skip to content

Commit 362094b

Browse files
committed
Extract getReposToDownload method
1 parent e791e77 commit 362094b

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

extensions/ql-vscode/src/remote-queries/variant-analysis-monitor.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,12 @@ export class VariantAnalysisMonitor extends DisposableObject {
7676

7777
void this.logger.log('****** Retrieved variant analysis' + JSON.stringify(variantAnalysisSummary));
7878

79-
if (variantAnalysisSummary.scanned_repositories) {
80-
variantAnalysisSummary.scanned_repositories.forEach(scannedRepo => {
81-
if (this.shouldDownload(scannedRepo, scannedReposDownloaded)) {
82-
this.scheduleForDownload(scannedRepo, variantAnalysisSummary);
83-
void commands.executeCommand('codeQL.autoDownloadVariantAnalysisResult', scannedRepo, variantAnalysisSummary);
84-
scannedReposDownloaded.push(scannedRepo.repository.id);
85-
}
86-
});
87-
}
79+
const repoResultsToDownload = this.getReposToDownload(variantAnalysisSummary, scannedReposDownloaded);
80+
81+
repoResultsToDownload.forEach(scannedRepo => {
82+
scannedReposDownloaded.push(scannedRepo.repository.id);
83+
this.scheduleForDownload(scannedRepo, variantAnalysisSummary);
84+
});
8885

8986
if (variantAnalysisSummary.status === 'completed') {
9087
break;
@@ -110,6 +107,17 @@ export class VariantAnalysisMonitor extends DisposableObject {
110107
return (!alreadyDownloaded.includes(scannedRepo.repository.id) && scannedRepo.analysis_status === 'succeeded');
111108
}
112109

110+
private getReposToDownload(
111+
variantAnalysisSummary: VariantAnalysisApiResponse,
112+
alreadyDownloaded: number[]
113+
): VariantAnalysisScannedRepository[] {
114+
if (variantAnalysisSummary.scanned_repositories) {
115+
return variantAnalysisSummary.scanned_repositories.filter(scannedRepo => this.shouldDownload(scannedRepo, alreadyDownloaded));
116+
} else {
117+
return [];
118+
}
119+
}
120+
113121
private async sleep(ms: number) {
114122
return new Promise(resolve => setTimeout(resolve, ms));
115123
}

0 commit comments

Comments
 (0)