Skip to content

Commit

Permalink
fixes No Deployment if totalDeployments exist
Browse files Browse the repository at this point in the history
  • Loading branch information
e-for-eshaan committed Dec 30, 2024
1 parent 8605f85 commit b317ceb
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
NoDataImg
} from '@/content/DoraMetrics/DoraCards/sharedComponents';
import { useAuth } from '@/hooks/useAuth';
import { useCountUp } from '@/hooks/useCountUp';
import {
useCurrentDateRangeLabel,
useStateDateConfig
Expand Down Expand Up @@ -56,10 +55,6 @@ export const WeeklyDeliveryVolumeCard = () => {
const dateRangeLabel = useCurrentDateRangeLabel();
const deploymentFrequencyProps = useAvgIntervalBasedDeploymentFrequency();

const deploymentFrequencyCount = useCountUp(
deploymentFrequencyProps.count || 0
);

const { addPage } = useOverlayPage();
const deploymentsConfigured = true;
const isCodeProviderIntegrationEnabled = integrationSet.has(
Expand Down Expand Up @@ -209,11 +204,12 @@ export const WeeklyDeliveryVolumeCard = () => {
color={deploymentFrequencyProps.color}
sx={{ fontSize: '3em' }}
>
{deploymentFrequencyProps.count ? (
`${deploymentFrequencyCount}`
) : (
<Line>No Deployments</Line>
)}
<Line>
{getDeploymentCountString(
deploymentFrequencyProps.count,
totalDeployments
)}
</Line>
</Line>
{Boolean(
deploymentFrequencyProps.count ||
Expand Down Expand Up @@ -319,3 +315,11 @@ export const WeeklyDeliveryVolumeCard = () => {
</CardRoot>
);
};

const getDeploymentCountString = (count: number, totalDeployments: number) => {
if (totalDeployments === 0) return 'No Deployments';
if (count) return `${count}`;

// backend doesn't send decimals, so if total deps exist, count cannot be zero, it's less than 1
return '<1';
};

0 comments on commit b317ceb

Please sign in to comment.