Skip to content

Commit 4e863e9

Browse files
Introduce method to add analysis results
We'd like to improve MRVA query gists by giving them more descriptive titles that contain useful information about the query. Let's add the number of query results to the title of the gist. To do this we'll first need to count all the results provided to us in the `analysisResults` array. There is an item in this array for each of the repositories we've queried, so we're introducing a method to sum up results for all the items in the array. Co-authored-by: Shati Patel <shati-patel@github.com>
1 parent f992679 commit 4e863e9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

extensions/ql-vscode/src/remote-queries/export-results.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { createGist } from './gh-actions-api-client';
1111
import { RemoteQueriesManager } from './remote-queries-manager';
1212
import { generateMarkdown } from './remote-queries-markdown-generation';
1313
import { RemoteQuery } from './remote-query';
14-
import { AnalysisResults } from './shared/analysis-result';
14+
import { AnalysisResults, sumAnalysesResults } from './shared/analysis-result';
1515

1616
/**
1717
* Exports the results of the currently-selected remote query.

extensions/ql-vscode/src/remote-queries/shared/analysis-result.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,9 @@ export const getAnalysisResultCount = (analysisResults: AnalysisResults): number
9090
const rawResultCount = analysisResults.rawResults?.resultSet.rows.length || 0;
9191
return analysisResults.interpretedResults.length + rawResultCount;
9292
};
93+
94+
/**
95+
* Returns the total number of results for an analysis by adding all individual repo results.
96+
*/
97+
export const sumAnalysesResults = (analysesResults: AnalysisResults[]) =>
98+
analysesResults.reduce((acc, curr) => acc + getAnalysisResultCount(curr), 0);

0 commit comments

Comments
 (0)