Skip to content

refactor(operational): migrate Reports/Operations pages to v2 metrics endpoints#76

Open
efr-nox wants to merge 12 commits intotetherto:developfrom
efr-nox:refactor/operational-rt-api-v2
Open

refactor(operational): migrate Reports/Operations pages to v2 metrics endpoints#76
efr-nox wants to merge 12 commits intotetherto:developfrom
efr-nox:refactor/operational-rt-api-v2

Conversation

@efr-nox
Copy link
Copy Markdown

@efr-nox efr-nox commented Apr 27, 2026

Summary

Migrates the single-site Reports > Operations pages to the v2 /auth/metrics/* API. Mirrors the pattern of #73 for Financial. Each refactored hook collapses the legacy tail-log + FE unwrap/reduce into a thin useGetMetrics*Query wrapper. Response shapes match handlers in miningos-app-node:develop and were verified live against dev-moria.tether.to.

Per-page status

Page Status
Dashboard Hashrate / Consumption / Efficiency on v2. Miners-status chart kept on legacy (see BE gap 1).
Hashrate All three tabs (Site / MiningUnit / MinerType) on v2 via `groupBy=miner
Energy Site + MinerView (per-type / per-container) on v2 via groupBy. See granularity note below.
Efficiency Site view on v2; KPI now reads BE-supplied summary.avgEfficiencyWThs. MinerType + MinerUnit tabs on legacy until BE ships groupBy on /auth/metrics/efficiency.
Miners Deferred. Doughnut needs realtime per-miner-type counts (type_cnt); no v2 endpoint surfaces that. Historical card needs error + notMining on /metrics/miner-status.

Energy MinerView granularity

Migrated from tail-log stat-5m, limit=1 (latest 5-minute snapshot) to /auth/metrics/consumption?groupBy=... (daily aggregate, stat-1D). The selector only exposes 1D / 7D / 30D / Custom day-range, so _last(log) is "yesterday's per-group avg power", which is the meaningful snapshot for this view. Confirmed with BE.

Remaining BE gaps

  1. /auth/metrics/miner-status missing categories. Returns only { online, offline, sleep, maintenance }; folds error and not-mining counts silently into online. Dashboard MinersStatusChart and MinersReport historical card stay on legacy until error + notMining are surfaced.
  2. groupBy not yet on /auth/metrics/efficiency. Blocks Efficiency MinerType/MinerUnit tabs.

Verified

  • Response shapes match types for all 8 endpoints (probed live against dev-moria with grouped + non-grouped variants).
  • Typecheck, lint, and full test suite (3100 tests) pass.

@efr-nox efr-nox marked this pull request as ready for review May 4, 2026 17:50
arif-dewi
arif-dewi previously approved these changes May 5, 2026
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.

2 participants