Outvi V reads a remote magpie through `magpie web`. The Usage page
bucketed calls by the server's days and hours, so a call at 9:00 in
UTC+8 showed under 1:00.
What changed:
- The Usage page (plugins/usage/page.js) names its browser's IANA zone
in ?tz= on /api/usage, /api/usage/requests, /api/usage/heatmap, the
CSV link and the export.
- usage.Zone turns the name into one cached *time.Location per name, so
a Filter holding it stays a comparable cache key. An empty or unknown
name, or a zone that keeps this computer's clock, is time.Local, so
the desktop page, the tray and the TUI see no change and share caches.
- Filter.Zone carries the zone. Today/7d/30d, the chart's hour and day
buckets and labels, the Day filter and the heatmap's days are all
read in it (Clock().In(zone)). The summary cache is keyed by period
and zone, and the request-page cache by the reader's date.
- Shared days from other computers are read with a 2-day margin, not
1, since two zones can be 26h apart.
- Limit and quota resets are unchanged. The gateway's
/v1/magpie/usage stays on the computer's zone.
Run at e435b8867 + this change:
- gofmt -l and go vet on internal/usage, internal/usageapi and
internal/gui: darwin, GOOS=linux -tags nogui, and GOOS=windows. The
vet ran before the new _test files were added.
- go test ./internal/usage ./internal/usageapi and
-tags nogui ./internal/gui: ok with TZ=UTC and with
TZ=Asia/Shanghai.
- New tests:
- TestUsageReadsTheViewersZone and TestZoneNames (internal/usage).
- TestUsageRoutesReadTheViewersZone (internal/gui) asks the routes
with ?tz= naming a zone other than the server's.
- Each holds usage.Clock and checks the hour label, today's
membership, the Day filter, the week chart's day label and the
heatmap's days. With no ?tz=, the server's days are kept.
Broken by hand:
- Clock().In(zone) / Clock().In(f.loc()) back to Clock(): red in both
zones (Summary, Requests, ledger, heatmap, /api/usage,
/api/usage/requests, /api/usage/heatmap).
- The Day filter read in time.Local: red under TZ=UTC.
- The summary's and chart's bucketing in time.Local: the week-day label
check goes red under TZ=UTC. Under TZ=Asia/Shanghai the chosen
moment falls on one date in both zones, so it can't tell there.
Each was restored after.
Not tried:
- A Playwright GUI test with timezoneId in Chromium and WebKit was
not written. The GUI suite and usage-stale-answer.test.cjs (which got
a usageZoneQ stub) were not run: the disk was at ~350 MB free.
- TestCoreScriptBudget was not run again after the change. app.js is
untouched, and page.js is a plugin page outside the core budget.
- A real remote `magpie web` from another zone, and the Windows box.
- Siblings left alone:
- The Sessions tab buckets by the server's days and hours in its
cached rollups, and its "By hour" card labels them with the
browser's zone name.
- The Routing history's day files are the server's days.
These need issues of their own.