Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix data rate in menu #618

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions react/src/DealTransfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,12 @@ export function DealTransfersMenuItem(props) {

// Get average transfer rate over last 10 seconds
var total = 0
const tenSecondsAgo = new Date().getTime() - 11 * 1000
for (const point of points) {
if (point.At.getTime() > tenSecondsAgo) {
const megabits = 8 * Number(point.Bytes) / 1e6
total += megabits
}
const subset = points.slice(points.length-10)
for (const point of subset) {
const megabits = 8 * Number(point.Bytes) / 1e6
total += megabits
}
dataRate = total / 10
dataRate = total / subset.length
}

return <Link key="deal-transfers" className="menu-item" to="/deal-transfers">
Expand All @@ -101,4 +99,4 @@ export function DealTransfersMenuItem(props) {
<b>{toFixed(dataRate, 1)}</b> Mbps (10s avg)
</div>
</Link>
}
}