Skip to content

Commit

Permalink
fix: don't display - placeholder for JS false equivalent types ( eg…
Browse files Browse the repository at this point in the history
… 0 or [] ) (#6)

* fix: don't display `-` placeholder for JS false equivalent types ( eg.: 0 or [] )

* fix: remove joining references

* fix: possible infinity calculation
  • Loading branch information
PudgyPug authored May 23, 2024
1 parent 968340a commit aaaf962
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
1 change: 0 additions & 1 deletion api/types/node-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type NodeNetwork = {
active: number
standBy: number
desired: number
joining: number
syncing: number
}
load: {
Expand Down
1 change: 0 additions & 1 deletion model/node-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export interface NodeNetwork {
active: number
standby: number
desired: number
joining: number
syncing: number
load: number
nodeLoad: {internal: number, external: number}
Expand Down
4 changes: 2 additions & 2 deletions pages/network/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function Network() {
<div>Active validators: {nullPlaceholder(network.active)}</div>
<div>Standby validators: {nullPlaceholder(network.standby)}</div>
<div>Desired network size: {nullPlaceholder(network.desired)}</div>
<div>Joining / Syncing: {nullPlaceholder(network.joining)} / {nullPlaceholder(network.syncing)}</div>
<div>Syncing: {nullPlaceholder(network.syncing)}</div>
</div>
</div>
<div className="flex flex-col items-stretch">
Expand All @@ -30,7 +30,7 @@ export default function Network() {
<h1 className="font-semibold mb-3">Network Health - Coming Soon</h1>
<div
className="bg-white text-stone-500 rounded-xl p-8 text-sm [&>*]:pb-2 flex flex-col flex-grow justify-center">
<div>Current A:S Ratio: {network.active/network.standby * 100}%</div>
<div>Current A:S Ratio: {network.standby > 0 ? network.active/network.standby * 100 : 0}%</div>
<div>Target A:S Ratio: {nullPlaceholder(null)}</div>
<div>Network health: {nullPlaceholder(null)}%
</div>
Expand Down
2 changes: 1 addition & 1 deletion utils/null-placerholder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function nullPlaceholder(value: string | number | null, placeholder = '-') {
return value ? value : placeholder;
return value != null ? value : placeholder;
}

0 comments on commit aaaf962

Please sign in to comment.