1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-13 13:48:59 +02:00

fix: N/A only on NaN

Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
andreas-unleash 2024-03-21 11:35:49 +02:00
parent c24045dc99
commit aea2f613df
No known key found for this signature in database
GPG Key ID: 86EF87A739B39099
2 changed files with 6 additions and 6 deletions

View File

@ -159,7 +159,7 @@ describe('useFilteredFlagTrends', () => {
potentiallyStale: 0,
averageUsers: 0,
averageHealth: undefined,
flagsPerUser: 'N/A',
flagsPerUser: '0.0',
});
});
});

View File

@ -42,14 +42,14 @@ export const useFilteredFlagsSummary = (
},
);
const flagsPerUser = users?.total ? sum.total / users.total : 0;
const flagsPerUserCalculation = sum.total / users.total;
const flagsPerUser = Number.isNaN(flagsPerUserCalculation)
? 'N/A'
: flagsPerUserCalculation.toFixed(1);
return {
...sum,
flagsPerUser:
Number.isNaN(flagsPerUser) || flagsPerUser === 0
? 'N/A'
: flagsPerUser.toFixed(1),
flagsPerUser,
averageUsers,
averageHealth: sum.total
? ((sum.active / (sum.total || 1)) * 100).toFixed(0)