Skip to content

feat: implement patch 17#24

Merged
mehdiasadli merged 1 commit into
mainfrom
v26-04-17
Apr 29, 2026
Merged

feat: implement patch 17#24
mehdiasadli merged 1 commit into
mainfrom
v26-04-17

Conversation

@mehdiasadli
Copy link
Copy Markdown
Contributor

@mehdiasadli mehdiasadli commented Apr 29, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added admin filtering and sorting by PDR, QDR, and TDR metrics in staff dashboards
    • Introduced public analytics sections on pack, topic, and question pages with charts, leaderboards, and player statistics
    • Added topic subset picker when starting games to select specific topics (minimum 5 required)
    • Updated game progress display formatting

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xamsa-web Ready Ready Preview, Comment Apr 29, 2026 5:21am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR introduces public analytics displays for packs, topics, and questions; enables hosts to select topic subsets when starting games with minimum constraints; adds PDR/TDR/QDR metrics to admin dashboards with filtering and sorting; and updates game progress displays to reflect session-specific topic ordering rather than pack-wide ordering.

Changes

Cohort / File(s) Summary
Admin Filter UI Components
apps/web/src/components/admin/filters/admin-packs-filters.tsx, admin-questions-filters.tsx, admin-topics-filters.tsx
Added numeric range filtering for PDR (packs), QDR (questions), and TDR (topics) metrics. Each filter now reads min/max query parameters, includes them in active filter counts, and renders corresponding number input fields in the filter dialog.
Admin Dashboard Tables
apps/web/src/routes/dashboard/packs/index.tsx, questions/index.tsx, topics/index.tsx
Extended sorting options and added new columns for PDR, QDR, and TDR metrics respectively, displaying values formatted to two decimal places.
Game Topic Selection & Session Ordering
apps/web/src/components/start-game-card.tsx, packages/api/src/modules/game/included-topics.ts
StartGameCard now includes a topic picker UI that fetches available topics, enforces minimum topic constraints, and passes selected topic orders to game creation. Backend resolver function determines session topic ordering from explicit selections or all pack topics.
Game Service & Session Logic
packages/api/src/modules/game/service.ts
Game service now handles session-specific topic ordering: initializes games from first included topic, respects topic order sequences when advancing between topics, and persists included topic pack orders for later retrieval. All "last topic" checks now reference session inclusion rather than pack-wide topic count.
Game Progress & Display Components
apps/web/src/components/game-header.tsx, host-controls.tsx, player-view.tsx, apps/web/src/lib/session-topic-progress.ts
Updated progress text generation to use formatted session-aware progress line, replacing direct pack order references. New utility function computes and formats progress using session topic ordering when available.
Public Analytics UI
apps/web/src/components/public-analytics-section.tsx
New component rendering comprehensive analytics dashboards with loading/error states, stat cards, pie/bar charts for click outcomes, and leaderboard tables for players and hosts, driven by union payload type for pack/topic/question analytics.
Analytics Page Integration
apps/web/src/routes/packs/$packSlug/index.tsx, packs/$packSlug/topics/$topicSlug/index.tsx, packs/$packSlug/topics/$topicSlug/questions/$questionSlug/index.tsx
Added React Query calls to fetch analytics for packs, topics, and questions, integrating PublicAnalyticsSection component into respective pages with loading and error handling.
Analytics Computation
packages/api/src/modules/analytics/public-stats.ts
New module computing comprehensive analytics: game/host counts, click outcome distributions with percentages, first/last session dates, and top-10 leaderboards (buzzers, correct, incorrect, played) using Prisma transactions and raw SQL queries.
Analytics API Endpoints
packages/api/src/modules/pack/router.ts, pack/service.ts, topic/router.ts, topic/service.ts, question/router.ts, question/service.ts
Added public/protected endpoints for fetching pack, topic, and question analytics, with access control enforcement (public packs/published or owned topics; questions for session users).
Admin Query Building
packages/api/src/modules/admin/build-where.ts, admin/service.ts
Extended admin query builders to accept and conditionally apply minPdr/maxPdr, minTdr/maxTdr, minQdr/maxQdr range filters. Admin service now selects metric fields in pack, topic, and question listings.
Database Schema & Migration
packages/db/prisma/migrations/20260429120000_game_included_topic_pack_orders/migration.sql, prisma/schema/game.prisma, packages/schemas/src/db/schemas/enums/GameScalarFieldEnum.schema.ts, db/schemas/models/Game.schema.ts
Added includedTopicPackOrders JSONB column to game table and corresponding Prisma/Zod schema definitions for storing session-specific topic orderings.
Validation Schemas
packages/schemas/src/modules/admin.ts, modules/game.ts, modules/public-analytics.ts, modules/listings/admin.ts
Extended admin filter/sort schemas to support PDR/TDR/QDR fields, added sessionTopicPackOrders and topicPackOrders to game schemas, and created new PublicAnalyticsClickMix and PackAnalyticsOutput schemas with leaderboard/host rankings.
Release Notes & Constants
packages/utils/src/app-releases.ts, utils/src/constants.ts
Bumped app version to 2026-04-17 with release highlights for staff metrics filtering, public analytics, and topic subset game selection. Added MIN_TOPICS_PER_GAME_SUBSET constant (value 5).

Sequence Diagram

sequenceDiagram
    actor Host
    participant StartGameCard as Frontend: StartGameCard
    participant TopicQuery as Frontend: useQuery Topics
    participant GameService as Backend: game.startGame
    participant GameDB as Database: Game Record

    Host->>StartGameCard: Click "Start Game"
    activate StartGameCard
    StartGameCard->>TopicQuery: Fetch topics for pack
    activate TopicQuery
    TopicQuery-->>StartGameCard: Return topic list
    deactivate TopicQuery
    
    Host->>StartGameCard: Select topic subset (≥5 topics)
    StartGameCard->>GameService: startGame({topicPackOrders: [1,3,5,7,9...]})
    activate GameService
    
    GameService->>GameService: Validate orders exist in pack
    GameService->>GameService: Enforce MIN_TOPICS_PER_GAME_SUBSET
    GameService->>GameDB: Create game with includedTopicPackOrders
    activate GameDB
    GameDB-->>GameService: Game created, currentTopicOrder = first order
    deactivate GameDB
    
    GameService-->>StartGameCard: Return game with sessionTopicPackOrders
    deactivate GameService
    
    StartGameCard->>Host: Close picker, start live game
    deactivate StartGameCard
    
    Note over Host,GameDB: Game now progresses through<br/>selected topics in session order
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly Related PRs

  • Feat/game #3 — Both PRs modify core game components (game-header, host-controls, start-game-card), game service, and schemas to implement session-aware game logic and topic ordering, indicating directly overlapping changes.
  • feat: implement new features #22 — Both PRs restructure game service initialization and topic/question ordering logic, affecting findOneGame and startGame behavior for session-specific fields.

Suggested Labels

app:web, pkg:api, database, size:xl

Poem

🐰 A bundle of topics, now bundled with care,
Analytics dancing through pack-topic-pair,
Hosts cherry-pick questions they want to share,
Progress displays show the path they declare!
With filtering fierce and leaderboards fair,
The quiz-verse expands—let's hare-brace and dare! 🎯

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'feat: implement patch 17' is vague and generic, using non-descriptive terms that don't convey meaningful information about the changeset's primary purpose. Replace with a more specific title that highlights the main feature(s), such as 'feat: add public analytics and topic subset selection for games' or 'feat: add analytics dashboards and game topic filters'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v26-04-17

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@mehdiasadli mehdiasadli merged commit b0e096e into main Apr 29, 2026
4 of 5 checks passed
@mehdiasadli mehdiasadli deleted the v26-04-17 branch April 29, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant