Skip to content

feat(webui): redesign Owner Platform analytics as a fleet dashboard - #626

Merged
jatmn merged 2 commits into
mainfrom
feat/618-platform-analytics-dashboard
Nov 13, 2026
Merged

jatmn merged 2 commits into
mainfrom
feat/618-platform-analytics-dashboard

Conversation

@jatmn

@jatmn jatmn commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Closes #618

Problem

Owners → Platform analytics showed one metric at a time behind toggle buttons, repeated y-axis labels ("1", "1", "0") for small counts, raw guild IDs in the server table, a long explanatory paragraph, and .stats cards unlike the redesigned Analytics and Database Usage pages. The read was also fixed at 30 days with no comparison, so the deeper fleet view asked for in the issue comment was not possible.

Change

Page (frontend/app.js, still under Owner in the normal web UI)

  • 7d / 30d / 90d range selector, Refresh, and one short info tooltip in the page header.
  • KPI strip (KpiTile, same as community Analytics): Servers, Members (with a partial badge), Net growth, Joins, Leaves, Warnings, Bans, Spam hits, Mod actions, Timeouts. Each tile shows the change from the previous range and a daily sparkline.
  • Enforcement per day: all five metrics as small multiples, with no toggle. A metric with no records shows "None in this range" instead of a scale.
  • Fleet membership per day: joins, leaves and net growth. With no joins or leaves it shows an explicit empty message.
  • Rankings: most and least active servers, plus biggest movers against the previous range. "Actions" counts automod enforcement and moderator commands once each, the same rule the heat map uses.
  • Share of fleet bans, spam hits and mod actions by server.
  • Server table:
    • Every column sorts.
    • Filters by name or ID, and by status: All servers, Active, Departed, With activity, or Member directory incomplete.
    • Each row shows the icon and name, with the ID as secondary text and in the tooltip.
    • Members column with an importing, unverified or unavailable badge.
    • Actions with their change from the previous range.
    • A share-of-fleet bar for each metric.
  • The paragraph is gone. A one-line note appears only when member totals are partial or unavailable.

API (crates/api/src/web/platform.rs)

  • POST /api/platform/analytics?days=7|30|90 defaults to 30. Any other value returns 400.
  • members.by_guild maps each counted server to its current member count and directory coverage. An active server missing from the map could not be read.

Data (src/db/analytics.rs)

  • platform_analytics is still a single statement in one primary snapshot. It uses materialized CTEs that cover both windows.
  • It adds fleet previous totals and, for each server, previous, active, name and icon_hash. Name and icon come from guild_join_info.
  • It returns a row for every active server, even one with no activity. Departed servers appear only if they have records in either window.
  • 90-day membership comparisons stay null, because the daily counters are kept for 92 days. The guild view uses the same rule.

Shared (frontend/charts.js, frontend/icons.js)

  • EnforcementChart and MembershipChart gain the empty-series text. On the community page this only adds text.
  • RankList rows can show a share or a signed change in place of the count.
  • icons.js gains chevron icons for the sorted column, following the shared-icon and no-glyph rules.

Validation

  • bash scripts/ci-preflight.sh --affected: passed on the exact committed tree. That run included contracts, fmt, dylint, clippy and tests for api, bot, updater, core and integration, the dual_process_smoke run, service boundaries, ESLint, the frontend Node suites (state, contrast, warmup, sr-only, package, administration), cargo deny, and cargo audit. cargo audit reported one advisory, which does not fail pull requests.
  • New and updated tests:
    • scripts/frontend-state-test.mjs: six Platform analytics tests. They cover metrics shown together, empty states, names and icons, directory badges, rankings and shares, sorting and filtering, range reads, stale retention on failed refreshes, and the initial failure. All six fail against the base frontend.
    • src/db/analytics/tests.rs: previous-window totals for the fleet and each server, display facts, a zero row for an active server, the departed server that has only previous-window activity, and the 90-day null membership comparison.
    • crates/api/src/web/enrollment_tests.rs: route range validation (7, 30, 90, default, 14 → 400, non-owner → 403) and by_guild coverage.
  • Real browser check (not committed): I rendered the built dist/frontend in headless Firefox against a mock owner API, at 1440 px in light and dark themes and at 760 px. Results: no horizontal page scroll, KPI strip on one row at 1440 px, no wrapped numbers, no overflowing rank rows, and the server table fits at 1440 px.

Limitations

  • The remote-database CI job (remote libSQL) was not run locally because it needs Docker. The existing analytics_reads_fit_the_remote_snapshot_budget test still exercises the platform read over a delayed local Hrana fixture.
  • The browser check used mock API data. There was no live Discord or Bunny data.
  • At medium widths, the three rank panels per row are narrow and truncate names. The community Analytics page behaves the same way.
  • The "Known members" figure was dropped from the top strip because its label was truncated and the issue didn't ask for it. The API still returns members.known.

Summary by Sourcery

Replace the single-metric owner platform analytics view with a comprehensive fleet dashboard for comparing activity, membership, and server-level performance across configurable time ranges.

New Features:

  • Redesign Owner Platform analytics as a fleet dashboard with selectable 7-, 30-, and 90-day ranges, KPI trends, daily enforcement and membership charts, rankings, fleet shares, and a sortable, filterable server table.
  • Expose per-server display metadata, activity comparisons, membership directory coverage, and previous-period fleet totals through the owner analytics API.

Bug Fixes:

  • Represent empty activity series with explicit empty-state messaging instead of misleading scales or missing data.
  • Preserve previously loaded analytics while refreshes fail and clearly indicate stale or unavailable data.

Enhancements:

  • Add previous-period comparisons, server names and icons, departed-server visibility, member coverage badges, per-metric fleet-share bars, and accessible table sorting and filtering.
  • Extend shared analytics charts and ranking components to support empty series and alternate share or change displays.

Documentation:

  • Document the expanded owner platform analytics range, comparisons, rankings, shares, and server directory capabilities.

Tests:

  • Add API, database, and frontend coverage for range validation, previous-window aggregation, display metadata, empty states, directory status, rankings, shares, sorting, filtering, and refresh behavior.

Platform analytics now reads a 7, 30 or 90-day range and shows every
metric at once: KPI tiles with the change from the previous range,
small-multiple enforcement bars, fleet membership growth, most and least
active servers, biggest movers, each server's share of bans, spam hits
and mod actions, and a sortable, filterable server table with names,
icons, share bars and member directory status. The explanatory
paragraph is replaced by a tooltip and a one-line partial-totals note.

The platform read adds previous-window totals, server display facts and
zero rows for every active server in the same single statement; the
route validates ?days and reports per-server directory coverage.

Refs #618
@jatmn jatmn self-assigned this Nov 13, 2026
@jatmn

jatmn commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@pullfrog review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Important

The required CI gate fails on an EOF whitespace error. No behavioral issues found in the reviewed changes.

Reviewed changes Fleet dashboard redesign and its API/data changes against #618, including the expanded owner requirements.

  • Fleet dashboard: Range selection, KPI comparisons, simultaneous charts, rankings, fleet shares, and sortable/filterable server rows with names, icons, and directory coverage.
  • API and aggregation: Owner-only range validation, per-server member totals, previous-window aggregates, and active/departed server display facts in the primary snapshot.
  • Shared components and coverage: Chart empty states, ranking labels, styling, documentation, and regression tests. All 15 selected analytics frontend tests passed locally, including the existing browser layout check; API/SQL tests were inspected but not rerun locally. Fixtures do not establish live-provider behavior.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using gpt-6.1-sol | 𝕏

Comment thread scripts/frontend-state-test.mjs Resolved
Removing the final Platform analytics test block left its blank separator at EOF, which fails the git diff --check whitespace gate.

Refs #618
@jatmn

jatmn commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@pullfrog review

@jatmn
jatmn marked this pull request as ready for review November 13, 2026 19:37
@sourcery-ai

sourcery-ai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Sorry @jatmn, this account has used its review budget of 1,500,000 diff characters for the last 7 days.

You can request another review in 22 hours and 39 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found. The previous EOF whitespace finding is fixed, and the required CI passed check now passes.

Reviewed changes Full fleet-dashboard redesign against #618 and its expanded owner requirements.

  • Owner dashboard: Selectable ranges, KPI comparisons, simultaneous enforcement/membership charts, rankings, fleet shares, and sortable/filterable server rows with display names, icons, and directory coverage.
  • API and data: Owner-only range validation, per-server member totals, previous-window aggregation, and active/departed server metadata within the primary snapshot.
  • Shared components and coverage: Chart empty states, alternate ranking labels, styles, documentation, and API/data/frontend regression tests. All 15 selected analytics frontend tests passed locally after building assets, including the existing community Analytics Firefox layout check; the merge-base whitespace check also passed. Rust/API tests were inspected but not rerun locally. Frontend fixtures use mocked APIs, not live providers.

Pullfrog  | View workflow run | Using gpt-6.1-sol | 𝕏

@jatmn
jatmn merged commit 2f2d079 into main Nov 13, 2026
20 checks passed
@jatmn
jatmn deleted the feat/618-platform-analytics-dashboard branch November 13, 2026 20:04
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.

feat(webui): redesign Owner Platform analytics as an at-a-glance dashboard

1 participant