Skip to content

feat(admin): organisation-wide monthly stats page for admins - #2866

Open
mroderick wants to merge 3 commits into
masterfrom
feat/admin-stats-page
Open

feat(admin): organisation-wide monthly stats page for admins#2866
mroderick wants to merge 3 commits into
masterfrom
feat/admin-stats-page

Conversation

@mroderick

@mroderick mroderick commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Super admins can now pull codebar-wide monthly numbers for any month range on an admin page and export the same figures as CSV. The page exists for grant reporting, where the current stats surface can only break numbers down per year.

image

Fixes #2860

  • One captioned table per metric group: attendance (check-ins and RSVPs, students and coaches), new sign-ups by role with a distinct-member total, and workshop counts — monthly columns plus totals for the selected range.
  • 3/6/12-month presets in complete calendar months (default: the most recent 3) or a custom start/end month range with inline validation; Download CSV always mirrors the displayed table.
  • Visible only to global admins: the admin area also admits chapter organisers, so the stats controller checks admin status itself for both the page and the CSV.
  • Figures are computed on request from existing tables; no new storage, jobs, or caching.

Review notes

  • The invalid-range split in Admin::StatsController#index: the page shows an inline error and keeps the last valid range; the CSV endpoint instead falls back to the default range.
  • Sign-up role assignment in Admin::Stats::Monthly: a member in both a Students and a Coaches group appears in both role rows but once in the total, so role rows may sum above it.
  • Deliberately not done: caching or precomputation (not needed at current scale), per-chapter breakdowns, and events/meetings — the page covers workshops only.
Background and scope
  • The page complements stats.codebar.io, which stays unchanged; feedback ratings remain there.
  • Sign-up rows count every member ever created, with no ban or terms filter — sign-ups are historical facts, so counts stay stable when a member is later banned or accepts the terms. Role rows use current group membership.
  • Check-in figures exist only where organisers recorded check-ins (the flow launched in March 2025), so older periods under-report them; the RSVP rows give a complete basis for the same period.
  • Custom ranges are capped server-side at 240 months; wider requests reuse the invalid-range path. Very wide tables scroll horizontally.
  • The CSV writes raw integers (no thousands separators) so it pastes cleanly into spreadsheets.

Post-deploy monitoring

  • Watch /admin/stats response times in Scout APM; the page runs three grouped aggregate queries per render with no caching.
  • Rollbar errors mentioning Admin::Stats or CookieOverflow are the rollback signal; revert the branch.
  • Validation window: the first week after deploy.

@mroderick
mroderick force-pushed the feat/admin-stats-page branch from c2c164c to bcd08ab Compare September 10, 2026 17:21
Admin::Stats::Range resolves 3/6/12-month presets anchored at the last
complete month and inclusive custom start/end month ranges: explicit
months take precedence over a preset, future end months clamp to the
last complete month, reversed ranges and spans beyond 240 months return
an explicit invalid state (the page shows an inline error, the CSV
export falls back to the default range), and absent or malformed input
falls back to the default 3 complete months.
Admin::Stats::Monthly computes organisation-wide monthly rows for any
resolved range entirely in Postgres: attendance (check-ins and RSVPs as
independent bases per role), sign-ups by current group membership with
distinct-member totals via a single left-join query, and workshop
counts — each grouped by calendar month in the app time zone, so cost
is independent of row counts. Totals are range totals only.
Admin::StatsController serves the HTML page and CSV export from one
action, enforcing the global-admin check itself on top of the admin
area's admins-plus-organisers default. The page renders one captioned
table per metric group with right-aligned, thousands-separated cells,
preset and custom-month GET forms with inline validation, and a
Download CSV link built from the resolved range so the export mirrors
the displayed table; the admin portal gains a Stats button beside
Chapter Status.
@mroderick
mroderick force-pushed the feat/admin-stats-page branch from bcd08ab to 53342a7 Compare September 10, 2026 17:32
@KimberleyCook

Copy link
Copy Markdown
Contributor

This is very very exciting 👀

@mroderick
mroderick marked this pull request as ready for review September 10, 2026 18:42
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.

Stats page for super admins

2 participants