A relay's /api/subscription/self tells usage per subscription, a list.
A balance path could only name one index (subscriptions.0), so several
active subscriptions read as the first, ".0 + .1" failed whole when only
one existed, and a weekly cap of 0 ("divides by 0") hid every amount of
the field.
Now a path goes through a list's items with "*" (a.*.used), or those
that match with "[key=value]" / "[key!=value]" (a[status=active].used,
also on an object: a.*.subscription[status=active].used). Such a path is
several values, made one by sum(), max(), min() or count(); arithmetic
between two of them goes item by item, so max(a.*.used / a.*.cap) is the
fullest window. Several values left outside a function are an error
naming the functions, not a guessed sum. Within a list an item without
the path, or divided by 0, is left out; max/min of nothing is an error.
In a field of several ";" amounts, one that can't be read shows "—"
(BalancePart.Error says why, as the card's hover on the Usage page and
in the panel) and the others still show; the read fails only when none
can be read. A single amount alone still fails as before.
The GUI hint (zh, zh-TW, ja, de) and `magpie provider` help say the new
syntax.
Run:
- TestBalancePathLists, with the reporter's literal JSON: against the
old balance.go it fails ("nothing at \"sum\" in the reply", and the
"—" cases error); passes now. TestReadBalancePath's one case that
expected a whole-field failure with one bad amount now expects it
only when every amount fails.
- go test -tags nogui ./internal/provider ./internal/cli ./internal/gui
under a temp HOME: ok.
- balance-parts, gui-de, gui-ja, gui-zh-tw, i18n-keys in Chromium and
WebKit: 14 pass. With the title lines removed, balance-parts fails on
the missing hover text.
- gofmt -l clean; GOOS=linux and GOOS=windows go vet -tags nogui on
provider and cli.
Not tried against the reporter's real relay.