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 authored Aug 22, 2024
1 parent 066c704 commit e426bf5
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 @@ -32,6 +32,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 @@ -99,11 +103,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 e426bf5

Please sign in to comment.