Skip to content

Commit

Permalink
Check is NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
yenienserrano committed Jun 6, 2023
1 parent a3db041 commit cc02f12
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ class WzStatusActionButtons extends Component {

const { connection: agentsCount } = agentsCountByManagerNodes?.data?.data?.agent_status;

const agentsActiveCoverage = (
(agentsCount.active / agentsCount.total) *
100
).toFixed(2);

this.props.updateStats({
agentsCountByManagerNodes: agentsCountByManagerNodes?.data?.data?.nodes,
agentsCount,
agentsCoverage: agentsCount?.total
? ((agentsCount?.active / agentsCount?.total) * 100).toFixed(2)
: 0,
agentsCoverage: isNaN(agentsActiveCoverage) ? 0 : agentsActiveCoverage,
});

const daemons = await this.statusHandler.clusterNodeStatus(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,21 @@ export class WzStatusOverview extends Component {
this.statusHandler.clusterAgentsCount()
])).map(response => response?.data?.data);
const { connection: agentsCount, configuration } = agentsCountByManagerNodes?.agent_status;

const agentsActiveCoverage = (
(agentsCount.active / agentsCount.total) *
100
).toFixed(2);
const agentsSyncedCoverage = (
(configuration.synced / configuration.total) *
100
).toFixed(2);

this.props.updateStats({
agentsCountByManagerNodes: agentsCountByManagerNodes.nodes,
agentsCount,
agentsSynced: configuration.total
? ((configuration.synced / configuration.total) * 100).toFixed(2)
: 0,
agentsCoverage: agentsCount.total
? ((agentsCount.active / agentsCount.total) * 100).toFixed(2)
: 0,
agentsSynced: isNaN(agentsSyncedCoverage) ? 0 : agentsSyncedCoverage,
agentsCoverage: isNaN(agentsActiveCoverage) ? 0 : agentsActiveCoverage,
});

this.props.updateClusterEnabled(clusterStatus && clusterStatus.enabled === 'yes');
Expand Down

0 comments on commit cc02f12

Please sign in to comment.