mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-05 17:53:12 +02:00
fix: do not show flagsPerUser when calculation results to NaN
Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
6518e6081a
commit
7b399d24e4
@ -39,6 +39,7 @@ interface IChartsProps {
|
|||||||
potentiallyStale: number;
|
potentiallyStale: number;
|
||||||
averageUsers: number;
|
averageUsers: number;
|
||||||
averageHealth?: string;
|
averageHealth?: string;
|
||||||
|
flagsPerUser?: string;
|
||||||
};
|
};
|
||||||
avgDaysToProduction: number;
|
avgDaysToProduction: number;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
@ -124,9 +125,7 @@ export const Charts: VFC<IChartsProps> = ({
|
|||||||
<FlagStats
|
<FlagStats
|
||||||
count={summary.total}
|
count={summary.total}
|
||||||
flagsPerUser={
|
flagsPerUser={
|
||||||
showAllProjects
|
showAllProjects ? summary.flagsPerUser : ''
|
||||||
? (summary.total / users.total).toFixed(2)
|
|
||||||
: ''
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
@ -83,11 +83,7 @@ export const FlagStats: React.FC<IFlagStatsProps> = ({
|
|||||||
</StyledRingContainer>
|
</StyledRingContainer>
|
||||||
|
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={flagsPerUser !== undefined && flagsPerUser !== ''}
|
||||||
flagsPerUser !== undefined &&
|
|
||||||
flagsPerUser !== '' &&
|
|
||||||
flagsPerUser !== 'NaN'
|
|
||||||
}
|
|
||||||
show={
|
show={
|
||||||
<StyledInsightsContainer>
|
<StyledInsightsContainer>
|
||||||
<StyledTextContainer>
|
<StyledTextContainer>
|
||||||
|
@ -22,7 +22,10 @@ export const useDashboardData = (
|
|||||||
);
|
);
|
||||||
const groupedMetricsData = useGroupedProjectTrends(metricsData);
|
const groupedMetricsData = useGroupedProjectTrends(metricsData);
|
||||||
|
|
||||||
const summary = useFilteredFlagsSummary(projectsData);
|
const summary = useFilteredFlagsSummary(
|
||||||
|
projectsData,
|
||||||
|
executiveDashboardData.users,
|
||||||
|
);
|
||||||
|
|
||||||
const avgDaysToProduction = useAvgTimeToProduction(groupedProjectsData);
|
const avgDaysToProduction = useAvgTimeToProduction(groupedProjectsData);
|
||||||
|
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import type { ExecutiveSummarySchemaProjectFlagTrendsItem } from 'openapi';
|
import type {
|
||||||
|
ExecutiveSummarySchema,
|
||||||
|
ExecutiveSummarySchemaProjectFlagTrendsItem,
|
||||||
|
} from 'openapi';
|
||||||
|
|
||||||
// NOTE: should we move project filtering to the backend?
|
// NOTE: should we move project filtering to the backend?
|
||||||
export const useFilteredFlagsSummary = (
|
export const useFilteredFlagsSummary = (
|
||||||
filteredProjectFlagTrends: ExecutiveSummarySchemaProjectFlagTrendsItem[],
|
filteredProjectFlagTrends: ExecutiveSummarySchemaProjectFlagTrendsItem[],
|
||||||
|
users: ExecutiveSummarySchema['users'],
|
||||||
) =>
|
) =>
|
||||||
useMemo(() => {
|
useMemo(() => {
|
||||||
const lastWeekId = filteredProjectFlagTrends.reduce((prev, current) => {
|
const lastWeekId = filteredProjectFlagTrends.reduce((prev, current) => {
|
||||||
@ -38,8 +42,13 @@ export const useFilteredFlagsSummary = (
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const flagsPerUser = sum.total / users.total;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...sum,
|
...sum,
|
||||||
|
flagsPerUser: Number.isNaN(flagsPerUser)
|
||||||
|
? 'N/A'
|
||||||
|
: flagsPerUser.toFixed(2),
|
||||||
averageUsers,
|
averageUsers,
|
||||||
averageHealth: sum.total
|
averageHealth: sum.total
|
||||||
? ((sum.active / (sum.total || 1)) * 100).toFixed(0)
|
? ((sum.active / (sum.total || 1)) * 100).toFixed(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user