Cache BQRS schemas in compare view

This commit is contained in:
Koen Vlaswinkel
2023-12-05 10:26:24 +01:00
parent b6ba0bbcb9
commit 331d39afcf
2 changed files with 24 additions and 25 deletions

View File

@@ -30,7 +30,9 @@ import { findResultSetNames } from "./result-set-names";
interface ComparePair {
from: CompletedLocalQueryInfo;
fromSchemas: BQRSInfo;
to: CompletedLocalQueryInfo;
toSchemas: BQRSInfo;
}
export class CompareView extends AbstractWebview<
@@ -57,7 +59,19 @@ export class CompareView extends AbstractWebview<
to: CompletedLocalQueryInfo,
selectedResultSetName?: string,
) {
this.comparePair = { from, to };
const fromSchemas = await this.cliServer.bqrsInfo(
from.completedQuery.query.resultsPaths.resultsPath,
);
const toSchemas = await this.cliServer.bqrsInfo(
to.completedQuery.query.resultsPaths.resultsPath,
);
this.comparePair = {
from,
fromSchemas,
to,
toSchemas,
};
await this.showResultsInternal(selectedResultSetName);
}
@@ -78,7 +92,10 @@ export class CompareView extends AbstractWebview<
currentResultSetName,
fromResultSet,
toResultSet,
] = await this.findCommonResultSetNames(from, to, selectedResultSetName);
] = await this.findCommonResultSetNames(
this.comparePair,
selectedResultSetName,
);
if (currentResultSetName) {
let rows: QueryCompareResult | undefined;
let message: string | undefined;
@@ -178,23 +195,15 @@ export class CompareView extends AbstractWebview<
}
private async findCommonResultSetNames(
from: CompletedLocalQueryInfo,
to: CompletedLocalQueryInfo,
{ from, fromSchemas, to, toSchemas }: ComparePair,
selectedResultSetName: string | undefined,
): Promise<[string[], string, RawResultSet, RawResultSet]> {
const {
commonResultSetNames,
currentResultSetDisplayName,
fromSchemas,
fromResultSetName,
toSchemas,
toResultSetName,
} = await findResultSetNames(
this.cliServer,
from,
to,
selectedResultSetName,
);
} = await findResultSetNames(fromSchemas, toSchemas, selectedResultSetName);
const fromResultSet = await this.getResultSet(
fromSchemas,

View File

@@ -1,18 +1,10 @@
import { CompletedLocalQueryInfo } from "../query-results";
import { CodeQLCliServer } from "../codeql-cli/cli";
import { BQRSInfo } from "../common/bqrs-cli-types";
export async function findResultSetNames(
cliServer: CodeQLCliServer,
from: CompletedLocalQueryInfo,
to: CompletedLocalQueryInfo,
fromSchemas: BQRSInfo,
toSchemas: BQRSInfo,
selectedResultSetName: string | undefined,
) {
const fromSchemas = await cliServer.bqrsInfo(
from.completedQuery.query.resultsPaths.resultsPath,
);
const toSchemas = await cliServer.bqrsInfo(
to.completedQuery.query.resultsPaths.resultsPath,
);
const fromSchemaNames = fromSchemas["result-sets"].map(
(schema) => schema.name,
);
@@ -47,9 +39,7 @@ export async function findResultSetNames(
currentResultSetDisplayName:
currentResultSetName ||
`${defaultFromResultSetName} <-> ${defaultToResultSetName}`,
fromSchemas,
fromResultSetName,
toSchemas,
toResultSetName,
};
}