Skip to content

fix(core): make "All cohorts" selector show a combined overview#26

Merged
FreekBes merged 2 commits into
codam-coding-college:masterfrom
CheapFuck:fix/core-all-cohorts-overview
Jun 17, 2026
Merged

fix(core): make "All cohorts" selector show a combined overview#26
FreekBes merged 2 commits into
codam-coding-college:masterfrom
CheapFuck:fix/core-all-cohorts-overview

Conversation

@CheapFuck

Copy link
Copy Markdown
Contributor

Bug

On the Common Core overview (/core/:year), the cohort selector has an All cohorts option. Selecting it navigates back to the latest cohort (e.g. 2026) instead of showing all cohorts.

Repro

  1. Open /core/2026 (Common Core Overview).
  2. Open the cohort dropdown and pick All cohorts.
  3. Observe the page jumps back to /core/2026.

Cause

The selector's change handler sends value 0 ("All cohorts") to /core/ (empty year). That matches the /core route, which is hardcoded to redirect to the latest cohort — so it bounces straight back.

This dropdown was copied from the /users/students selector, which does have a real all-cohorts view behind it. The core overview never had one.

Fix

  • getCommonCoreCohortData(prisma, year: number | null, ...) — a null year omits the per-year begin_at filter so every cohort is included, cached under core-all.
  • buildCommonCoreCache also pre-warms the combined view so the first request isn't slow.
  • New GET /core/all route, registered before /core/:year (otherwise all fails the 4-digit-year check and the handler returns without responding).
  • The selector now navigates to /core/all for "All cohorts", and that option is marked selected when no specific year is set.
  • The /core landing redirect to the latest cohort is unchanged.

Testing

  • tsc type-check passes (only the pre-existing unrelated scripts/ rootDir error remains).
  • Verified against a seeded local Postgres that /core/all returns exactly the union of every per-cohort query (one user in 2025, two in 2026 -> all three under /core/all).
  • Note: the combined view computes logtimes for all common-core students across cohorts, so it's a heavier query than a single cohort — mitigated by the existing cache + cache pre-warming on sync.

The cohort selector on the Common Core overview offered an "All cohorts"
option, but choosing it navigated to `/core/` which matches the `/core`
route. That route is hardcoded to redirect to the latest cohort, so the
page bounced straight back to the most recent year (e.g. 2026) instead of
showing all cohorts.

This was a copy/paste of the `/users/students` selector, which does have a
real all-cohorts view behind it; the core overview never did.

Fix:
- getCommonCoreCohortData now accepts `year: number | null`; a null year
  omits the per-year `begin_at` filter to include every cohort and caches
  under `core-all`.
- buildCommonCoreCache also pre-warms the combined view.
- Add a dedicated `GET /core/all` route, registered before `/core/:year`
  (otherwise `all` fails the 4-digit year check and the handler returns
  without responding).
- The selector now navigates to `/core/all` for the "All cohorts" option
  and marks it selected when no specific year is set.

The `/core` landing redirect to the latest cohort is unchanged.

@FreekBes FreekBes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice change! I would have removed the "All cohorts" option entirely (indeed mistakenly having added that option to the dropdown menu after copying it over), but having an option to display everyone is a nice addition.

One minor change requested: let's have /core display all cohorts instead of /core/all, similar to the /users/students route. The redirect to the latest cohort from /core can then be removed.

Address review: instead of redirecting /core to the latest cohort and
exposing the combined view at /core/all, /core now renders all cohorts
directly, mirroring /users/students. The /core/all route and the
latest-cohort redirect are removed; the selector's "All cohorts" option
navigates back to /core.
@CheapFuck

Copy link
Copy Markdown
Contributor Author

Done in 0cb4333/core now renders all cohorts directly (mirroring /users/students), and the /core/all route plus the latest-cohort redirect are removed. The selector's "All cohorts" option points back to /core.

@FreekBes FreekBes merged commit fa68ac2 into codam-coding-college:master Jun 17, 2026
1 check passed
@Codam-IT

Copy link
Copy Markdown

🎉 This PR is included in version 2.3.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants