Skip to content

feat(ui): wire the "FHIR resources over time" chart to real counts (#185)#216

Open
mauripunzueta wants to merge 2 commits into
mainfrom
feat/185-dashboard-resource-counts
Open

feat(ui): wire the "FHIR resources over time" chart to real counts (#185)#216
mauripunzueta wants to merge 2 commits into
mainfrom
feat/185-dashboard-resource-counts

Conversation

@mauripunzueta

Copy link
Copy Markdown
Contributor

Closes #185.

Context

The observability work merged in #150 stood up the Prometheus /metrics facility and the authenticated console resource-counts endpoint — but the dashboard's "FHIR resources over time" chart still rendered a hardcoded SVG with sample data (the code comments called this out as follow-up work). This PR wires that chart to real per-type cumulative counts, closing the remaining gap in #185.

Design decisions (resolving #185's open questions)

  • Server-side rendered, default tenant. The /ui dashboard is an operator view mounted outside the auth layer, so the chart renders the server's default tenant counts server-side (no browser token needed, no client JS).
  • No tenant leak. Per-tenant counts are still never exported to the public /metrics endpoint. This reuses the same storage count path as the authenticated console JSON endpoint — a JSON/render path, not a Prometheus label — consistent with the posture established in feat(observability): uptime, Prometheus /metrics, and OTLP traces across all servers #150.
  • UI stays storage-agnostic. Rather than making helios-ui depend on the persistence layer, the server registers a provider with a light process-global registry in helios-observability (mirroring the existing uptime/metrics globals); the UI reads a plain snapshot.

Changes

  • helios-observability — new dashboard module: a process-global DashboardProvider registry + plain DashboardSnapshot data types (no persistence/FHIR types, keeps the crate light).
  • helios-restStorageDashboardProvider (default tenant, 8 dashboard types, 30-day window) implementing that trait, registered in build_app. Extracted a shared resource_count_series helper so the console resource-counts handler and the dashboard provider share one cumulative-bucketing implementation.
  • helios-ui — depends on helios-observability; renders the real chart server-side (computed SVG polyline, y-axis ticks, x-axis dates) plus a legend of per-type totals that doubles as a ?type= series selector (progressive enhancement, works without JS). Falls back to placeholder data when no provider is registered. Drops the now-unused chart-unit-patients i18n key across en/es/de.
  • ROADMAP.md — flips "No performance metrics … Not planned" to implemented.

Verification

Opening this PR primarily to run CI: the authoring environment has no C linker, so cargo check/test/clippy could not be run locally. cargo tree confirms the dependency graph resolves. New unit tests cover the dashboard projection, chart geometry, formatting helpers, query parsing, and the empty/unknown-type fallbacks; the console resource-counts JSON shape is unchanged (existing integration tests still apply).

@mauripunzueta mauripunzueta force-pushed the feat/185-dashboard-resource-counts branch from 55b56c2 to 77d04d6 Compare July 7, 2026 17:38
)

The observability work merged in #150 stood up the Prometheus /metrics
facility and the authenticated console `resource-counts` endpoint, but the
dashboard's "FHIR resources over time" chart still rendered a hardcoded SVG
with sample data. This wires it to real per-type cumulative counts, closing
the remaining gap in #185.

Design: the chart is server-side rendered for the server's default tenant
(an operator view). Per-tenant counts are still never exported to the public
/metrics endpoint — this reuses the same storage count path as the console
JSON endpoint, not a Prometheus label.

- helios-observability: add a storage-agnostic `dashboard` module — a
  process-global `DashboardProvider` registry (mirroring the existing
  uptime/metrics globals) plus plain `DashboardSnapshot` data types. Keeps the
  crate free of any persistence dependency.
- helios-rest: add `StorageDashboardProvider` (default tenant, 8 dashboard
  types, 30-day window) implementing that trait, registered in `build_app`;
  extract a shared `resource_count_series` helper so the console
  `resource-counts` handler and the dashboard provider share one
  cumulative-bucketing implementation.
- helios-ui: depend on helios-observability (light); render the real chart
  server-side — computed SVG polyline, y-axis ticks, x-axis dates, a legend of
  per-type totals that doubles as a `?type=` series selector (progressive
  enhancement, no JS). Falls back to placeholder data when no provider is
  registered. Drops the now-unused `chart-unit-patients` i18n key across locales.
- ROADMAP.md: flip "No performance metrics … Not planned" to implemented.
@mauripunzueta mauripunzueta force-pushed the feat/185-dashboard-resource-counts branch from 77d04d6 to 06b6fde Compare July 7, 2026 17:46
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.12109% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/rest/src/dashboard.rs 92.07% 8 Missing ⚠️
crates/ui/src/lib.rs 99.68% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

mauripunzueta added a commit that referenced this pull request Jul 7, 2026
Raise #216 patch coverage: add a StorageDashboardProvider::snapshot test
against an in-memory backend (covers new() + the snapshot success path), and
UI tests for the single-point chart branch and short_date month validation.
Raise #216 patch coverage: add a StorageDashboardProvider::snapshot test
against an in-memory backend (covers new() + the snapshot success path), and
UI tests for the single-point chart branch and short_date month validation.
@mauripunzueta mauripunzueta force-pushed the feat/185-dashboard-resource-counts branch from 0585627 to 2d86169 Compare July 7, 2026 18:48
/// One daily point of a single resource type's cumulative growth curve.
#[derive(Clone, Debug)]
pub struct DashboardPoint {
/// `YYYY-MM-DD` (UTC) label for the bucket.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is day the most specific precision that we can support? I'd like the chart to have better precision - to mins or seconds.

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.

Expose Prometheus resource-count metrics to power the "FHIR Resources over time" UI chart

2 participants