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>
This commit is contained in:
@@ -11,7 +11,7 @@ import { createGist } from './gh-actions-api-client';
|
||||
import { RemoteQueriesManager } from './remote-queries-manager';
|
||||
import { generateMarkdown } from './remote-queries-markdown-generation';
|
||||
import { RemoteQuery } from './remote-query';
|
||||
import { AnalysisResults } from './shared/analysis-result';
|
||||
import { AnalysisResults, sumAnalysesResults } from './shared/analysis-result';
|
||||
|
||||
/**
|
||||
* Exports the results of the currently-selected remote query.
|
||||
|
||||
@@ -90,3 +90,9 @@ export const getAnalysisResultCount = (analysisResults: AnalysisResults): number
|
||||
const rawResultCount = analysisResults.rawResults?.resultSet.rows.length || 0;
|
||||
return analysisResults.interpretedResults.length + rawResultCount;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the total number of results for an analysis by adding all individual repo results.
|
||||
*/
|
||||
export const sumAnalysesResults = (analysesResults: AnalysisResults[]) =>
|
||||
analysesResults.reduce((acc, curr) => acc + getAnalysisResultCount(curr), 0);
|
||||
|
||||
Reference in New Issue
Block a user