Use the repos defined in the query result instead of the query (#1268)
This commit is contained in:
@@ -71,6 +71,7 @@ export class RemoteQueriesInterfaceManager {
|
|||||||
const totalResultCount = queryResult.analysisSummaries.reduce((acc, cur) => acc + cur.resultCount, 0);
|
const totalResultCount = queryResult.analysisSummaries.reduce((acc, cur) => acc + cur.resultCount, 0);
|
||||||
const executionDuration = this.getDuration(queryResult.executionEndTime, query.executionStartTime);
|
const executionDuration = this.getDuration(queryResult.executionEndTime, query.executionStartTime);
|
||||||
const analysisSummaries = this.buildAnalysisSummaries(queryResult.analysisSummaries);
|
const analysisSummaries = this.buildAnalysisSummaries(queryResult.analysisSummaries);
|
||||||
|
const totalRepositoryCount = queryResult.analysisSummaries.length;
|
||||||
const affectedRepositories = queryResult.analysisSummaries.filter(r => r.resultCount > 0);
|
const affectedRepositories = queryResult.analysisSummaries.filter(r => r.resultCount > 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -80,7 +81,7 @@ export class RemoteQueriesInterfaceManager {
|
|||||||
queryText: query.queryText,
|
queryText: query.queryText,
|
||||||
language: query.language,
|
language: query.language,
|
||||||
workflowRunUrl: `https://github.com/${query.controllerRepository.owner}/${query.controllerRepository.name}/actions/runs/${query.actionsWorkflowRunId}`,
|
workflowRunUrl: `https://github.com/${query.controllerRepository.owner}/${query.controllerRepository.name}/actions/runs/${query.actionsWorkflowRunId}`,
|
||||||
totalRepositoryCount: query.repositories.length,
|
totalRepositoryCount: totalRepositoryCount,
|
||||||
affectedRepositoryCount: affectedRepositories.length,
|
affectedRepositoryCount: affectedRepositories.length,
|
||||||
totalResultCount: totalResultCount,
|
totalResultCount: totalResultCount,
|
||||||
executionTimestamp: this.formatDate(query.executionStartTime),
|
executionTimestamp: this.formatDate(query.executionStartTime),
|
||||||
|
|||||||
@@ -226,7 +226,8 @@ export class RemoteQueriesManager extends DisposableObject {
|
|||||||
|
|
||||||
private async askToOpenResults(query: RemoteQuery, queryResult: RemoteQueryResult): Promise<void> {
|
private async askToOpenResults(query: RemoteQuery, queryResult: RemoteQueryResult): Promise<void> {
|
||||||
const totalResultCount = queryResult.analysisSummaries.reduce((acc, cur) => acc + cur.resultCount, 0);
|
const totalResultCount = queryResult.analysisSummaries.reduce((acc, cur) => acc + cur.resultCount, 0);
|
||||||
const message = `Query "${query.queryName}" run on ${query.repositories.length} repositories and returned ${totalResultCount} results`;
|
const totalRepoCount = queryResult.analysisSummaries.length;
|
||||||
|
const message = `Query "${query.queryName}" run on ${totalRepoCount} repositories and returned ${totalResultCount} results`;
|
||||||
|
|
||||||
const shouldOpenView = await showInformationMessageWithAction(message, 'View');
|
const shouldOpenView = await showInformationMessageWithAction(message, 'View');
|
||||||
if (shouldOpenView) {
|
if (shouldOpenView) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export interface RemoteQuery {
|
|||||||
queryText: string;
|
queryText: string;
|
||||||
language: string;
|
language: string;
|
||||||
controllerRepository: Repository;
|
controllerRepository: Repository;
|
||||||
repositories: Repository[];
|
|
||||||
executionStartTime: number; // Use number here since it needs to be serialized and desserialized.
|
executionStartTime: number; // Use number here since it needs to be serialized and desserialized.
|
||||||
actionsWorkflowRunId: number;
|
actionsWorkflowRunId: number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -308,7 +308,6 @@ export async function runRemoteQuery(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const remoteQuery = await buildRemoteQueryEntity(
|
const remoteQuery = await buildRemoteQueryEntity(
|
||||||
repositories,
|
|
||||||
queryFile,
|
queryFile,
|
||||||
queryMetadata,
|
queryMetadata,
|
||||||
owner,
|
owner,
|
||||||
@@ -395,7 +394,6 @@ async function ensureNameAndSuite(queryPackDir: string, packRelativePath: string
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function buildRemoteQueryEntity(
|
async function buildRemoteQueryEntity(
|
||||||
repositories: string[],
|
|
||||||
queryFilePath: string,
|
queryFilePath: string,
|
||||||
queryMetadata: QueryMetadata | undefined,
|
queryMetadata: QueryMetadata | undefined,
|
||||||
controllerRepoOwner: string,
|
controllerRepoOwner: string,
|
||||||
@@ -407,11 +405,6 @@ async function buildRemoteQueryEntity(
|
|||||||
// The query name is either the name as specified in the query metadata, or the file name.
|
// The query name is either the name as specified in the query metadata, or the file name.
|
||||||
const queryName = queryMetadata?.name ?? path.basename(queryFilePath);
|
const queryName = queryMetadata?.name ?? path.basename(queryFilePath);
|
||||||
|
|
||||||
const queryRepos = repositories.map(r => {
|
|
||||||
const [owner, repo] = r.split('/');
|
|
||||||
return { owner: owner, name: repo };
|
|
||||||
});
|
|
||||||
|
|
||||||
const queryText = await fs.readFile(queryFilePath, 'utf8');
|
const queryText = await fs.readFile(queryFilePath, 'utf8');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -423,7 +416,6 @@ async function buildRemoteQueryEntity(
|
|||||||
owner: controllerRepoOwner,
|
owner: controllerRepoOwner,
|
||||||
name: controllerRepoName,
|
name: controllerRepoName,
|
||||||
},
|
},
|
||||||
repositories: queryRepos,
|
|
||||||
executionStartTime: queryStartTime,
|
executionStartTime: queryStartTime,
|
||||||
actionsWorkflowRunId: workflowRunId
|
actionsWorkflowRunId: workflowRunId
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user