Repository navigation
Gateway page: precomputed overview endpoint, faster windows, stable view - #135
Closed
bansalayush247 wants to merge 7 commits into
Closed
bansalayush247 wants to merge 7 commits into
bansalayush247 wants to merge 7 commits into
Conversation
The gateway page often showed stale data until a manual refresh, and lost the selected time window on every reload. - Refetch when Nginx answers from an expired cache entry (X-Cache-Status STALE/UPDATING), with a growing delay until fresh data arrives; refresh a minute after each load and on returning to the tab, never interrupting a load in flight; keep statuses and "seen" times ticking. - Keep the window, status filter, sort and direction in the URL; remember the last window picked for visits without one. - Render as soon as the recorded gateways arrive; run the live registry lookup in the background with a timeout and skip it for offline federations (it blocked the page for ~60 s). - Tie each response and error to its window: a switch shows the previous window's numbers dimmed, a failed refresh keeps the last data with a Try again that shows progress, and a failed first load keeps the controls. - Reload once per build when a lazy chunk is gone after a deploy, and add error boundaries so a crash can no longer blank the whole app. - Remount federation pages per id so another federation's data never shows. - Smaller UX fixes: no banners in normal states, stacked cards on phones, one accessible element per availability strip, aria-pressed controls, endpoints as copyable text, chart via echarts/core with dark-mode colours and time-zone-stable day labels, guarded localStorage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egraded - Apply the saved or system theme in index.html before the first paint; the page shipped with class="dark" and only corrected it after React started, so light-theme users saw a dark flash on every load. - Count a gateway as online for up to 15 minutes since it was last seen. With 5-minute polls and answers cached for up to 6 minutes, the old 10-minute limit marked healthy gateways degraded after one late poll. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ging uptime - Mark the activity CTEs NOT MATERIALIZED. Materialized, the planner estimated one row for each and nested-looped ~10k x 10k rows: the 90D query for Global Bitcoin Federation took 55 s, now 4 s, same results. - Treat a gateway missing from the registry for 7 days as retired: stop writing "not seen" samples for it, and leave samples taken after that out of per-gateway uptime and the trend. Previously every gateway ever seen counted as 0% forever (E-Cash Club showed 28.6% uptime while both active gateways were at 100%). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A gateway last seen more than 7 days ago has left the federation (the same rule the backend now uses). Show it as "retired" instead of "offline", hide it from the default list behind its own Retired filter, and leave it out of the header counts, uptime and observed figures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The retired-gateway filter compared last_seen with `$2 - make_interval(...)`. Postgres can't infer $2's type there and read it as an interval, so every poll failed with "operator does not exist: timestamp with time zone >= interval" and rolled back: no gateway was marked seen after the upgrade. Cast the poll time explicitly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each request ran the gateway and trend queries from scratch, 4 s for 90D, so the page leaned on Nginx serving expired cache entries and had to detect them and retry. - A background task rebuilds every federation's gateways and uptime trend for every window every 5 minutes, one query at a time, and keeps them in memory. Requests answer from that in ~1 ms. A missing entry (right after a restart) is computed on the spot but not stored, so unknown federation IDs can't grow the cache. - New GET /federations/:id/gateways/overview?window= returns both lists computed at the same moment, with computed_at. ?include=gateways or ?include=trend returns only that part. - Remove /gateways?window= and /gateways/uptime-trend, now unused. - The page makes one request, shows "Updated" from computed_at, and drops the stale-cache detection and retries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bansalayush247
added a commit
to bansalayush247/fedimint-observer
that referenced
this pull request
Oct 9, 2026
Brings the gateway page fixes and the precomputed /gateways/overview endpoint (upstream PR fedimint#135) onto master, alongside the UTXO claims work. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On staging the overview task took ~75 s of every 5-minute cycle and raised the VPS CPU from ~27% to ~35%, slowing the other database work too. Most of that went into 30D and 90D, which barely change in 5 minutes. - 24h and 7D still refresh every 5 minutes, 30D every 30 and 90D every hour. The first cycle after a restart builds all of them. - Remove the 1h window: the page never offered it and it is shorter than the 5-minute poll interval. window=1h now returns the usual error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 10, 2026
Member
Author
|
Superseded by #137, which keeps only the gateway fetch and gateway details page changes and also fixes the connection leak in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the gateway page fast, current and stable. The backend now precomputes each federation's gateway list and uptime trend in the background and serves both from one endpoint. The frontend keeps its view across reloads and recovers from errors. Retired gateways no longer drag uptime down.
Changes
Backend
GET /federations/:id/gateways/overview?window=returns the gateway list and the uptime trend computed at the same moment, pluscomputed_at.?include=gatewaysor?include=trendreturns only that part.GET /federations/:id/gatewaysandGET /federations/:id/gateways/uptime-trend(unstable API, only used by our frontend)./overviewreturns the same data.1hwindow: the page never offered it and it is shorter than the 5-minute poll interval.NOT MATERIALIZED: the planner misestimated them as one row and nested-looped ~10k × 10k rows (90D: 55 s → 4 s, same results).Frontend
Testing
cargo clippy,tsc,eslintandnpm run buildpass./overviewanswers in ~1–2 ms for every window, including 90D;includevariant returns only the requested parts, and an invalid value returns an error;