feat: study cohorts — group enrollment with shared progress & leaderboard - #1040
Open
zeemscript wants to merge 1 commit into
Open
feat: study cohorts — group enrollment with shared progress & leaderboard#1040zeemscript wants to merge 1 commit into
zeemscript wants to merge 1 commit into
Conversation
…oard Implements bakeronchain#1027: small learner squads per course with shared progress, a private discussion thread, and a group leaderboard. Backend: - Migration 025: cohorts + cohort_members tables (with undo) - POST /api/cohorts (auth, creator auto-joins), GET /api/cohorts?course= - POST /api/cohorts/:id/join — capacity-checked in a transaction with row lock, idempotent; POST /api/cohorts/:id/leave — idempotent - GET /api/cohorts/:id — members with per-member approved-milestone progress (joined against milestone_reports) and group completion %, ordered as the squad leaderboard - Jest/supertest coverage: capacity enforcement, join/leave idempotency, group progress aggregation (16 tests) Frontend: - "Squads" tab on the course page (LessonView) - SquadsPanel: browse/join/create cohorts for a course - CohortDetailView: roster with progress bars, group completion ring, leaderboard, and cohort-scoped discussion reusing CommentSection (thread id "cohort-<id>", members only) - React Query hooks in useCohorts.ts; vitest component coverage Also fixes a corrupted package-lock.json entry (node_modules/esbuild/node_modules/@esbuild/aix-ppc64 had no version) that made npm install/ci fail with "Invalid Version".
Contributor
|
please fix checks |
Contributor
|
Hi @zeemscript, Just want to confirm if you are still working on this issue |
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.
Summary
Implements #1027 — study cohorts (squads): small groups of learners enrolled in the same track who share a group progress view, a private discussion thread, and a group leaderboard. Closes #1027.
What's included
Database
025_study_cohorts.sql(+.undo.sql):cohortsandcohort_memberstables per the issue spec, with indexes oncourse_slug/learner_addrand amax_members > 0check.Backend (
createCohortsRouter, mounted under/api)POST /api/cohorts— create (auth + zod validation); validates the course exists; creator auto-joins in a transaction.GET /api/cohorts?course=— list cohorts with live member counts.POST /api/cohorts/:id/join— capacity-checked inside a transaction with aSELECT ... FOR UPDATErow lock so concurrent joins can't oversubscribe; idempotent when already a member.POST /api/cohorts/:id/leave— idempotent no-op when not a member.GET /api/cohorts/:id— members with per-member progress joined againstmilestone_reports(approved only) plus a group completion %; ordered by milestones completed so the payload doubles as the leaderboard. Falls back to lesson count for courses without milestone rows.Frontend
LessonView, alongside Lesson/Forum).SquadsPanel: browse/join cohorts for the course or create one.CohortDetailView: member roster with progress bars, group completion ring, ranked leaderboard (crown for Bump the npm-minor group with 11 updates #1, "You" marker), and an embedded discussion thread reusingCommentSectionscoped to thread idcohort-<id>(members only).src/hooks/useCohorts.tsusing the sharedapiFetchJsonwrapper.Tests
server/src/tests/cohorts-api.test.ts(16 tests): capacity enforcement, join/leave idempotency, group progress aggregation, auth/validation, course-not-found.src/components/cohorts/CohortDetailView.test.tsx(4 tests): ring/roster rendering, leaderboard "You" marker, cohort-scoped discussion, full-squad join disabled.Repo fix (needed to build)
package-lock.jsonhad a corrupted entry (node_modules/esbuild/node_modules/@esbuild/aix-ppc64with no version field) that madenpm install/npm cifail withnpm error Invalid Version:. Removed the stub so npm resolves the proper top-level entry.Acceptance criteria
milestone_reports)CommentSection)Verification
tsc --noEmitclean.vite buildsucceeds; no new eslint errors.LessonView.test.tsxfailures are identical on pristinemain(18 failed) — unrelated to this change.