Skip to content

feat: fixed trailing 24 h chart with avg/peak readout - #15

Open
salmun-nister wants to merge 1 commit into
nulluserid:mainfrom
salmun-nister:feat/last-24h
Open

salmun-nister wants to merge 1 commit into
nulluserid:mainfrom
salmun-nister:feat/last-24h

Conversation

@salmun-nister

Copy link
Copy Markdown

Fixes #11

1. Stitch the two day files

Model.js gains a pure helper (testable outside QML):

// Trailing 24 h of per-minute typical downlink, oldest -> newest, as a fixed
// 1440-slot window: yesterday's minutes (cur+1 ... 1439) then today's (0 ... cur).
// A day file stores {} for minutes with no data, which maps to a null gap.
function rolling24h(prevMinutes, todayMinutes, curMinute) { ... }

Panel.qml reads day-<yesterday>.json alongside today's (same dish partition), with prevDayStamp recomputed on the existing 2 s refresh, so the rollover needs no restart. stampOffset() steps the local date with Date.setDate rather than subtracting 24 h, which survives DST.

Path hygiene while wiring the second file: dayDir/dayBase stay empty until the dish identity arrives, so FileView does not probe a root-level day file that never exists, and both day FileViews set printErrors: false - yesterday's file legitimately does not exist on a fresh install and the reload would otherwise log a warning every 2 s.

2. Window summary instead of the duplicated live value

// Model.js - mean of the non-null entries; null when there is no data
function mean(values) { ... }
-              title: "TODAY"
-              valueText: ... s.live.typicalDownMbps ... "peak " + Model.fmtMbps(root.dayPeak) ...
+              title: "LAST 24H"
+              valueText: {
+                var parts = []
+                if (root.dayAvg !== null) parts.push("avg " + Model.fmtMbps(root.dayAvg))
+                if (root.dayPeak !== null) parts.push("peak " + Model.fmtMbps(root.dayPeak))
+                return parts.length ? parts.join(" · ") : "—"
+              }

Side effect worth noting: the line no longer collapses to a single label when the link goes idle, because window statistics exist even with no current samples.

Testing

  • window length is always 1440; index mapping matches the source files with zero mismatches;
  • at cur = 0, the window equals yesterday's 1 ... 1439 plus today's 0;
  • no previous file -> 1440 slots, only today populated; no files -> all null, renders —;
  • mean(): [1,2,3] -> 2, [1,null,3] -> 2, [] -> null, null -> null;
  • visual: a synthetic full-day file fills the band edge to edge; the real day file reproduces the expected right-hand band.

Known limitation

DST days (23 h / 25 h) shift the window by an hour twice a year; minute-of-day arithmetic is used deliberately instead of epoch math.

Scope

Display only. No Go changes, so backend/bin/starlinkd is untouched and the release gate's byte-identical check is unaffected. Independent of the other open PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chart clears at local midnight and the section value duplicates the live rate

1 participant