Repository navigation
feat(webui): dense Analytics page redesign - #612
Merged
Merged
Conversation
Owner
Author
|
@pullfrog review |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes across the Analytics frontend, API, database aggregation, tests, and documentation against #587 and its clarified scope.
- Dashboard: Shared 7/30/90-day ranges, compact KPIs, enforcement and membership charts, ranked breakdowns, and a UTC heat map with progressive loading and chart readouts.
- Stored-data summaries: SQL aggregates current and previous windows; moderator names come from bounded member-directory lookups, without new Discord data fetches.
- Caching and authorization: Membership/range-scoped server and browser caches retain the existing permission and page-enrollment checks; browser entries clear on sign-out or authentication loss.
- Validation: All 12 focused Analytics state, contrast, and headless-Firefox layout tests passed locally after building frontend assets. GitHub’s
CI passedgate is green; Rust suites were not rerun locally. Browser tests use a stub API, not live Discord or Bunny.
gpt-6.1-sol | 𝕏
Replace the single-chart Analytics tab with a command-center grid that renders every panel from one summary read per range (7, 30 or 90 days): - compact KPI strip (members with a coverage badge, net growth, joins, leaves, warnings, bans, spam hits, mod actions, timeouts) with change against the previous period and daily sparklines; - aligned daily enforcement bars, joins/leaves with a running net line, top automod rules, mod actions by type and by moderator, and a weekday by UTC hour heat map, with hover and keyboard readouts of exact values; - the About text moved into the existing info tooltip. The API takes a validated days parameter and aggregates all panels in one core statement (counted events materialized once) plus one guild-store statement for directory totals and stored moderator names. Complete answers are cached for 30 seconds per membership and range after authorization; the browser reuses loaded ranges for 60 seconds and clears them on sign-out. No Discord call is made for analytics data. Closes #587 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jatmn
force-pushed
the
feat/587-analytics-redesign
branch
from
November 13, 2026 02:46
172c2a0 to
64ce9dc
Compare
Owner
Author
|
@pullfrog review |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes across all 14 files, including the Analytics dashboard, stored-data aggregation, membership-aware caching, and regression coverage.
- Dashboard: Shared date ranges, compact KPIs, daily enforcement and membership charts, ranked breakdowns, heat map, and responsive theme styling.
- Backend: SQL summary aggregation, previous-period comparisons, bounded stored-name lookups, and authorization-before-cache access.
- Validation: All 8 focused analytics frontend tests passed, including the headless Firefox layout check; all 26 contrast/CSS tests passed. Rust tests were not rerun locally; GitHub’s
CI passedcheck is successful. Browser data was stubbed, with no live-provider validation. - Documented limits: Membership charts show cumulative net change rather than historical member counts; cold reads still aggregate retained raw enforcement records.
gpt-6.1-sol | 𝕏
This was referenced Dec 3, 2026
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.

🤖 Fixer (jatmn's agent)
Closes #587
Summary
The Analytics tab is now a dense, command-center grid. Every panel is visible at once and follows one 7 / 30 / 90-day range selector. Everything comes from one summary request per range that is aggregated in SQL from records the bot already stores. Nothing on the analytics path calls Discord for data.
Header: a one-line
Analyticsheader with the server and range, the range selector (a labelled group of7d/30d/90dtoggle buttons witharia-pressed), and the "About these trends" text moved into the existingInfoTip.KPI strip: nine equal tiles (Members, Net growth, Joins, Leaves, Warnings, Bans, Spam hits, Mod actions, Timeouts). Each shows a compact number, with the exact value in the title and accessible label, its change against the previous period of the same length, and a daily sparkline. Member coverage is a small
partial/unverifiedbadge instead of inline text. Numbers use a locale-independent compact format (10.4k,1.2M,2T), never wrap, and stay at most 18px.Panels:
Tooltips and axes: hover or arrow keys (Home/End/Escape) show exact per-day values in a readout, and every day column also has a native
<title>. Axes use integer ticks for sparse counts, and day labels are evenly spaced and edge-aligned.Backend:
/api/guilds/{id}/analyticstakes?days=7|30|90(default 30; anything else is refused). One core statement returns everything:Counted events are materialized once in a CTE, so
eventsis scanned and its JSON parsed once. One guild-store statement returns the directory size, coverage and stored names for up to 8 moderators (bounded at 32 IDs).Caching: the API caches complete answers for 30 s per guild, membership and range. The cache is checked only after authorization and page-membership checks, holds at most 256 entries, and is skipped when the directory is unavailable. The browser reuses a loaded range for 60 s, both when switching ranges and when returning to the tab, and clears it on sign-out or auth loss.
Progressive render: the header, KPI strip and all six panel frames render immediately with busy placeholders and fill in when the response arrives.
CSS: all new styles are in one delimited section at the end of
frontend/style.css. Every selector there starts with.analytics-pageor.an-, and a test enforces that. The series colors are scoped tokens for light and dark.The owner Administration analytics still uses
TrendChart/TrendMetricPickerunchanged. The branch is rebased onto #602 (icons). Its glyph-free source test caught the typographic minus sign, which is now written as the−escape. The rendered output is unchanged.Already covered by #599/#605
pageHeader("Analytics", …)infrontend/app.jstabAnalytics, styled by.page-header,.page-header-detailand.page-header-actionsinfrontend/style.css, and tested by "no page renders the old multi-line hero card markup" inscripts/frontend-state-test.mjs. I kept that header and only added the range selector and info tip to it.frontend/style.css(--ui-font-size,--ui-font-size-sm,--card-p,--ui-gap,--stat-value-size: 1.25rem, plus.stats .stat,.stat-titleand.stat-value) for both themes. The analytics section builds on those tokens.InfoTipinfrontend/app.js(the.info-tip*rules infrontend/style.css), used then only on the Dashboard. I reuse it here for "About these trends", which was still an inline paragraph on main..sr-onlyinfrontend/style.css, so thefigcaptioninfrontend/charts.jsTrendChartis hidden on screen but still read (scripts/frontend-sr-only-test.mjs). The new charts instead userole="img"with summaryaria-labels and anaria-describedbyreadout.Everything else in #587 was still open on main: the KPI comparisons, sparklines and badge, the multi-panel grid, breakdowns, heat map, tooltips and ticks, range selector, server and client caching, and profiling.
Profiling (before = main de11955, after = this branch)
I measured with the API's own test fixture: the real router, session, authorization, a local SQLite core database and an activated guild store, with the Discord OAuth endpoints stubbed and counted. I seeded 90 days of data at 30 or 300 enforcement records per day. Each figure is the first request for that URL and then the median of 20 repeats. This is a debug build (SQLite compiled at
-O0), so absolute times are inflated; the release-SQLite table below gives the SQL cost alone.SQL statement only, release SQLite 3.46, same data with 180 days stored (best of 5):
/users/@meor token calls for analytics data.Tests
Run on the final head 172c2a0, rebased on main 96a5ad0:
bash scripts/ci-preflight.sh(full Linux preflight, no--only): passed, "CI test gates passed". Results:--no-default-features216 passeddual_process_smoke --ignoredpassed-D warnings(also API--no-default-features), service boundaries,git diff --check, cargo deny and cargo audit all cleanIt also passed in full on the pre-rebase commit.
New and updated tests:
Backend aggregation (
src/db/analytics/tests.rs):Guild store (
src/db/guild_data/tests/member_directory.rs): name precedence (nickname, then global name, then username), nameless and unknown IDs omitted, a snowflake above 2^53, and the 32-ID bound.API (
crates/api/src/web/enrollment_tests.rs,state.rs):days=14,0,-7,abcand unknown parameters are refusedFrontend (
scripts/frontend-state-test.mjs, jsdom):Seven of these fail on the old frontend (checked); the eighth is the existing no-hero test.
Real browser (headless Firefox, same file): 1280×800, 1920×1080 and 700×800 in light and dark. It checks:
This test caught two layout bugs that I then fixed: a KPI delta overflowing at 700px, and daisyUI's card
figurerule placing the readouts beside the charts.CSS (
scripts/frontend-contrast-test.mjs): every analytics selector stays inside its delimited section; series colors reach at least 3:1 on the panel and are distinct in both themes; muted text, badge and selected range meet 4.5:1; numbers use nowrap and tabular figures; the medium and narrow breakpoints restack the grid.Simulated boundaries: local SQLite, the in-repo libSQL HTTP fixture (not a live remote database), stubbed Discord OAuth endpoints, and the built app against a stub API in headless Firefox. I didn't load it against a live server or test it with a screen reader.
Open questions and assumptions
timeout_addand a mod-action event. Stacking would double count, so I used aligned small multiples with one shared hover day. Is that acceptable, or do you want grouped bars despite the density at 90 days?events,warnsandbansrows for the range and the previous period (indexed by guild and time). A daily enforcement rollup table would make cold reads proportional to days rather than records. That needs a migration, bot writes and the paired update protocol, so I left it out. Should it be a follow-up?config_version.User <id>, with the ID in the title.Summary by Sourcery
Replace the existing Analytics trends view with a dense, cached command-center dashboard backed by stored data and a unified range selector.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: