Skip to content

Commit

Permalink
fix: prevent NaN in stage output (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Sep 4, 2024
1 parent 8ed9430 commit c4195cd
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/utils/deployStages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ function round(value: number, precision: number): number {
}

function formatProgress(current: number, total: number): string {
if (total === 0) {
return '0/0 (0%)';
}

return `${current}/${total} (${round((current / total) * 100, 0)}%)`;
}

Expand Down Expand Up @@ -111,11 +115,12 @@ export class DeployStages {
{
label: 'Members',
get: (data): string | undefined =>
data?.sourceMemberPolling &&
formatProgress(
data.sourceMemberPolling.original - data.sourceMemberPolling.remaining,
data.sourceMemberPolling.original
),
data?.sourceMemberPolling?.original
? formatProgress(
data.sourceMemberPolling.original - data.sourceMemberPolling.remaining,
data.sourceMemberPolling.original
)
: undefined,
stage: 'Updating Source Tracking',
type: 'dynamic-key-value',
},
Expand Down

0 comments on commit c4195cd

Please sign in to comment.