Pass in successfulRepositoryCount
This commit is contained in:
@@ -35,6 +35,7 @@ Starting.args = {
|
||||
variantAnalysisStatus: VariantAnalysisStatus.InProgress,
|
||||
totalRepositoryCount: 10,
|
||||
completedRepositoryCount: 0,
|
||||
successfulRepositoryCount: 0,
|
||||
skippedRepositoryCount: 0,
|
||||
};
|
||||
|
||||
@@ -43,6 +44,7 @@ Started.args = {
|
||||
...Starting.args,
|
||||
resultCount: 99_999,
|
||||
completedRepositoryCount: 2,
|
||||
successfulRepositoryCount: 2,
|
||||
};
|
||||
|
||||
export const StartedWithSkippedRepositories = Template.bind({});
|
||||
@@ -56,6 +58,7 @@ Succeeded.args = {
|
||||
...Started.args,
|
||||
totalRepositoryCount: 1000,
|
||||
completedRepositoryCount: 1000,
|
||||
successfulRepositoryCount: 1000,
|
||||
variantAnalysisStatus: VariantAnalysisStatus.Succeeded,
|
||||
createdAt: new Date(1661262726000),
|
||||
completedAt: new Date(1661263446000),
|
||||
@@ -66,6 +69,7 @@ SucceededWithSkippedRepositories.args = {
|
||||
...Succeeded.args,
|
||||
totalRepositoryCount: 10,
|
||||
completedRepositoryCount: 10,
|
||||
successfulRepositoryCount: 10,
|
||||
skippedRepositoryCount: 6,
|
||||
};
|
||||
|
||||
|
||||
@@ -214,6 +214,16 @@ export function hasRepoScanCompleted(
|
||||
return isCompletedAnalysisRepoStatus(repo.analysisStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repo
|
||||
* @returns whether the repo scan completed successfully
|
||||
*/
|
||||
export function isRepoScanSuccessful(
|
||||
repo: VariantAnalysisScannedRepository,
|
||||
): boolean {
|
||||
return repo.analysisStatus === VariantAnalysisRepoStatus.Succeeded;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repo
|
||||
* @returns whether the repo scan has an artifact that can be downloaded
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
getSkippedRepoCount,
|
||||
getTotalResultCount,
|
||||
hasRepoScanCompleted,
|
||||
isRepoScanSuccessful,
|
||||
VariantAnalysis,
|
||||
VariantAnalysisScannedRepositoryDownloadStatus,
|
||||
VariantAnalysisScannedRepositoryState,
|
||||
@@ -69,6 +70,12 @@ export const VariantAnalysisHeader = ({
|
||||
?.length ?? 0
|
||||
);
|
||||
}, [variantAnalysis.scannedRepos]);
|
||||
const successfulRepositoryCount = useMemo(() => {
|
||||
return (
|
||||
variantAnalysis.scannedRepos?.filter((repo) => isRepoScanSuccessful(repo))
|
||||
?.length ?? 0
|
||||
);
|
||||
}, [variantAnalysis.scannedRepos]);
|
||||
const resultCount = useMemo(() => {
|
||||
return getTotalResultCount(variantAnalysis.scannedRepos);
|
||||
}, [variantAnalysis.scannedRepos]);
|
||||
@@ -130,6 +137,7 @@ export const VariantAnalysisHeader = ({
|
||||
variantAnalysisStatus={variantAnalysis.status}
|
||||
totalRepositoryCount={totalScannedRepositoryCount}
|
||||
completedRepositoryCount={completedRepositoryCount}
|
||||
successfulRepositoryCount={successfulRepositoryCount}
|
||||
skippedRepositoryCount={skippedRepositoryCount}
|
||||
resultCount={resultCount}
|
||||
createdAt={parseDate(variantAnalysis.createdAt)}
|
||||
|
||||
@@ -13,6 +13,7 @@ type Props = {
|
||||
|
||||
totalRepositoryCount: number;
|
||||
completedRepositoryCount: number;
|
||||
successfulRepositoryCount: number;
|
||||
skippedRepositoryCount: number;
|
||||
};
|
||||
|
||||
@@ -20,6 +21,7 @@ export const VariantAnalysisRepositoriesStats = ({
|
||||
variantAnalysisStatus,
|
||||
totalRepositoryCount,
|
||||
completedRepositoryCount,
|
||||
successfulRepositoryCount,
|
||||
skippedRepositoryCount,
|
||||
}: Props) => {
|
||||
if (variantAnalysisStatus === VariantAnalysisStatus.Failed) {
|
||||
@@ -35,7 +37,7 @@ export const VariantAnalysisRepositoriesStats = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
{formatDecimal(completedRepositoryCount)}/
|
||||
{formatDecimal(successfulRepositoryCount)}/
|
||||
{formatDecimal(totalRepositoryCount)}
|
||||
{showWarning && (
|
||||
<>
|
||||
|
||||
@@ -13,6 +13,7 @@ export type VariantAnalysisStatsProps = {
|
||||
|
||||
totalRepositoryCount: number;
|
||||
completedRepositoryCount: number;
|
||||
successfulRepositoryCount: number;
|
||||
skippedRepositoryCount: number;
|
||||
|
||||
resultCount?: number | undefined;
|
||||
@@ -32,6 +33,7 @@ export const VariantAnalysisStats = ({
|
||||
variantAnalysisStatus,
|
||||
totalRepositoryCount,
|
||||
completedRepositoryCount,
|
||||
successfulRepositoryCount,
|
||||
skippedRepositoryCount,
|
||||
resultCount,
|
||||
createdAt,
|
||||
@@ -79,6 +81,7 @@ export const VariantAnalysisStats = ({
|
||||
variantAnalysisStatus={variantAnalysisStatus}
|
||||
totalRepositoryCount={totalRepositoryCount}
|
||||
completedRepositoryCount={completedRepositoryCount}
|
||||
successfulRepositoryCount={successfulRepositoryCount}
|
||||
skippedRepositoryCount={skippedRepositoryCount}
|
||||
/>
|
||||
</StatItem>
|
||||
|
||||
@@ -20,6 +20,7 @@ describe(VariantAnalysisStats.name, () => {
|
||||
variantAnalysisStatus={VariantAnalysisStatus.InProgress}
|
||||
totalRepositoryCount={10}
|
||||
completedRepositoryCount={0}
|
||||
successfulRepositoryCount={0}
|
||||
skippedRepositoryCount={0}
|
||||
onViewLogsClick={onViewLogsClick}
|
||||
createdAt={new Date()}
|
||||
@@ -40,8 +41,11 @@ describe(VariantAnalysisStats.name, () => {
|
||||
expect(screen.queryAllByText("-").length).toBe(1);
|
||||
});
|
||||
|
||||
it("renders the number of repositories as a formatted number", () => {
|
||||
render({ totalRepositoryCount: 123456, completedRepositoryCount: 654321 });
|
||||
it("renders the number of successful repositories as a formatted number", () => {
|
||||
render({
|
||||
totalRepositoryCount: 123456,
|
||||
successfulRepositoryCount: 654321,
|
||||
});
|
||||
|
||||
expect(screen.getByText("654,321/123,456")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user