Skip to content

Commit

Permalink
fix: Prevent NaN (division by zero) on Dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mman committed Oct 22, 2024
1 parent 4d0f730 commit 6a3402d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/client/views/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function Dashboard() {
})

const deviceKeys = Object.keys(deviceStatistics || {}).sort()
const adjustedMeasurementRate = measurementRate !== 0 ? measurementRate : 0.001

const websocketStatus = useSelector((state: AppState) => state.websocketStatus)
if (websocketStatus !== "open") {
Expand Down Expand Up @@ -102,7 +103,7 @@ function Dashboard() {
</CCol>
<CCol className="text-end" xs="auto">
<strong> {deviceStats.measurementRate} </strong>(
{((deviceStats.measurementRate / measurementRate) * 100).toFixed(0)}
{((deviceStats.measurementRate / adjustedMeasurementRate) * 100).toFixed(0)}
%)
</CCol>
</CRow>
Expand All @@ -111,7 +112,7 @@ function Dashboard() {
<CProgress
className="progress-xs"
color="warning"
value={(deviceStats.measurementRate / measurementRate) * 100}
value={(deviceStats.measurementRate / adjustedMeasurementRate) * 100}
/>
</CCol>
</CRow>
Expand Down

0 comments on commit 6a3402d

Please sign in to comment.