Skip to content
Open
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ function fmtGB(v) {
return (n >= 100 ? n.toFixed(0) : n.toFixed(1)) + " GB"
}

// Lifetime usage for display. The daemon keeps `allTime` as completed days
// only (rolled at local midnight), so today's bytes are added here: otherwise
// ALL-TIME sits unchanged all day and can read below TODAY. Null-safe — a
// missing side counts as 0, both missing stays null.
function lifetimeGB(allTimeGB, todayGB) {
var a = num(allTimeGB)
var t = num(todayGB)
if (a === null && t === null) return null
return (a === null ? 0 : a) + (t === null ? 0 : t)
}

function fmtPct(v, decimals) {
var n = num(v)
return n === null ? "—" : n.toFixed(decimals === undefined ? 1 : decimals) + "%"
Expand Down
3 changes: 2 additions & 1 deletion Panel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,8 @@ Panel {
Text {
width: (parent.width - 2 * parent.spacing) * 0.40
text: root.hasData && s.usage
? "ALL-TIME ↓ " + Model.fmtGB(s.usage.allTimeDownGB) + " ↑ " + Model.fmtGB(s.usage.allTimeUpGB)
? "ALL-TIME ↓ " + Model.fmtGB(Model.lifetimeGB(s.usage.allTimeDownGB, s.usage.downGB))
+ " ↑ " + Model.fmtGB(Model.lifetimeGB(s.usage.allTimeUpGB, s.usage.upGB))
: ""
textFormat: Text.PlainText
elide: Text.ElideRight
Expand Down