Merge branch 'aeisenberg/analysis-results-on-restart' into aeisenberg/codeSnippet-handling
This commit is contained in:
Коммит
4bdf579ce2
|
@ -163,23 +163,17 @@ export class AnalysesResultsManager {
|
|||
}
|
||||
|
||||
|
||||
public async loadDownloadedArtifacts(
|
||||
public async loadDownloadedAnalyses(
|
||||
allAnalysesToCheck: AnalysisSummary[]
|
||||
) {
|
||||
const allDownloadedAnalyses = await asyncFilter(allAnalysesToCheck, x => this.isAnalysisDownloadedNotInMemory(x));
|
||||
|
||||
// Find all analyses that are already downloaded.
|
||||
const allDownloadedAnalyses = await asyncFilter(allAnalysesToCheck, x => this.isAnalysisDownloaded(x));
|
||||
// Now, ensure that all of these analyses are in memory. Some may already be in memory. These are ignored.
|
||||
await this.loadAnalysesResults(allDownloadedAnalyses);
|
||||
}
|
||||
|
||||
private async isAnalysisDownloadedNotInMemory(analysis: AnalysisSummary): Promise<boolean> {
|
||||
const queryId = analysis.downloadLink.queryId;
|
||||
const resultsForQuery = this.internalGetAnalysesResults(queryId);
|
||||
const analysisResults = resultsForQuery.find(r => r.nwo === analysis.nwo);
|
||||
if (analysisResults) {
|
||||
// We already have the results for this analysis in memory, no need to check further.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the analysis results are already downloaded, but not in memory
|
||||
private async isAnalysisDownloaded(analysis: AnalysisSummary): Promise<boolean> {
|
||||
return await fs.pathExists(createDownloadPath(this.storagePath, analysis.downloadLink));
|
||||
}
|
||||
|
||||
|
|
|
@ -46,14 +46,14 @@ export class RemoteQueriesInterfaceManager {
|
|||
this.getPanel().reveal(undefined, true);
|
||||
|
||||
await this.waitForPanelLoaded();
|
||||
const model = await this.buildViewModel(query, queryResult);
|
||||
const model = this.buildViewModel(query, queryResult);
|
||||
await this.postMessage({
|
||||
t: 'setRemoteQueryResult',
|
||||
queryResult: model
|
||||
});
|
||||
|
||||
// Ensure all pre-downloaded artifacts are loaded into memory
|
||||
await this.analysesResultsManager.loadDownloadedArtifacts(model.analysisSummaries);
|
||||
await this.analysesResultsManager.loadDownloadedAnalyses(model.analysisSummaries);
|
||||
|
||||
await this.setAnalysisResults(this.analysesResultsManager.getAnalysesResults(queryResult.queryId));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ export class RemoteQueriesInterfaceManager {
|
|||
* @param queryResult The result of the query.
|
||||
* @returns A fully created view model.
|
||||
*/
|
||||
private async buildViewModel(query: RemoteQuery, queryResult: RemoteQueryResult): Promise<RemoteQueryResultViewModel> {
|
||||
private buildViewModel(query: RemoteQuery, queryResult: RemoteQueryResult): RemoteQueryResultViewModel {
|
||||
const queryFileName = path.basename(query.queryFilePath);
|
||||
const totalResultCount = queryResult.analysisSummaries.reduce((acc, cur) => acc + cur.resultCount, 0);
|
||||
const executionDuration = this.getDuration(queryResult.executionEndTime, query.executionStartTime);
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as path from 'path';
|
|||
|
||||
import { DownloadLink, createDownloadPath } from '../../remote-queries/download-link';
|
||||
|
||||
describe('toDownloadPath', () => {
|
||||
describe('createDownloadPath', () => {
|
||||
it('should return the correct path', () => {
|
||||
const downloadLink: DownloadLink = {
|
||||
id: 'abc',
|
||||
|
|
|
@ -337,17 +337,18 @@ describe('Remote queries and query history manager', function() {
|
|||
// Load remoteQueryResult0.analysisSummaries[1] into memory
|
||||
await arm.downloadAnalysisResults(remoteQueryResult0.analysisSummaries[1], () => Promise.resolve());
|
||||
|
||||
expect(await (arm as any).isAnalysisDownloadedNotInMemory(remoteQueryResult0.analysisSummaries[0])).to.be.true;
|
||||
// on disk
|
||||
expect(await (arm as any).isAnalysisDownloaded(remoteQueryResult0.analysisSummaries[0])).to.be.true;
|
||||
|
||||
// in memory
|
||||
expect(await (arm as any).isAnalysisDownloadedNotInMemory(remoteQueryResult0.analysisSummaries[1])).to.be.false;
|
||||
expect(await (arm as any).isAnalysisDownloaded(remoteQueryResult0.analysisSummaries[1])).to.be.true;
|
||||
|
||||
// not downloaded
|
||||
expect(await (arm as any).isAnalysisDownloadedNotInMemory(remoteQueryResult0.analysisSummaries[2])).to.be.false;
|
||||
expect(await (arm as any).isAnalysisDownloaded(remoteQueryResult0.analysisSummaries[2])).to.be.false;
|
||||
});
|
||||
|
||||
it('should load downloaded artifacts', async () => {
|
||||
await arm.loadDownloadedArtifacts(remoteQueryResult0.analysisSummaries);
|
||||
await arm.loadDownloadedAnalyses(remoteQueryResult0.analysisSummaries);
|
||||
const queryId = rawQueryHistory[0].queryId;
|
||||
const analysesResultsNwos = arm.getAnalysesResults(queryId).map(ar => ar.nwo).sort();
|
||||
expect(analysesResultsNwos[0]).to.eq('github/vscode-codeql');
|
||||
|
|
Загрузка…
Ссылка в новой задаче