User stats endpoint + profile page #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
There is currently no way for users to see their game history or performance. The app has auth and game sessions but doesn't record results per user.
What to do
Database changes
quiz_results(already planned in spec.md asquiz_answers):id,user_id(FK touser.id),session_id,score,total_questions,game_mode,created_at.packages/db/src/db/schema.ts.packages/db/src/models/.API changes
apps/api/src/routes/userRouter.ts— mount on/api/v1/users.GET /api/v1/users/me/stats— requires auth. Returns games played, total score, average score, recent games.apps/api/src/controllers/gameController.tsfor reference).apps/api/src/services/gameService.tsto save results when the last question is answered.Frontend changes
apps/web/src/routes/profile.tsx— displays user info and stats.Acceptance criteria
Notes
The
GameSessionStorecurrently uses an in-memory store (InMemoryGameSessionStore). Game results should be written to Postgres via the model layer, not to the session store. The session store is ephemeral; stats must be durable.