⚡ Bolt: Optimize user lesson progress queries on dashboard and courses pages - #100
⚡ Bolt: Optimize user lesson progress queries on dashboard and courses pages#100projectamazonph wants to merge 1 commit into
Conversation
…s pages - Scoped user's lesson progress queries to the relevant lesson IDs that belong to the loaded courses. - Reduces database payload size, lowers network latency, and reduces memory consumption under large user lesson histories. - Verified with full test suites, linters, and type-checks passing. Co-authored-by: projectamazonph <286085559+projectamazonph@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
📝 WalkthroughWalkthroughThe courses and dashboard pages now restrict lesson-progress queries to lesson IDs from fetched published courses. Both pages skip the query when no lesson IDs exist and return an empty progress list. ChangesLesson progress query scoping
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/app/(dashboard)/courses/page.tsx (1)
40-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the shared scoped-progress query contract.
Both pages now duplicate the scoped query and empty-list behavior. Confirm existing regression coverage or add it before merge.
src/app/(dashboard)/courses/page.tsx#L40-L51: verify thelessonId.infilter,deletedAt: null, and skipped query for an empty lesson list.src/app/(dashboard)/dashboard/page.tsx#L33-L44: verify that aggregate counts use only the scoped progress records.As per coding guidelines, new features in
**/*.{ts,tsx,md,mdx}must include tests. Based on learnings, this repository uses Playwright for server-component/page-flow validation, so do not introduce page-rendering unit-test infrastructure.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/app/`(dashboard)/courses/page.tsx around lines 40 - 51, Cover the shared scoped-progress query contract with Playwright page-flow regression tests: in src/app/(dashboard)/courses/page.tsx lines 40-51, verify the lessonId.in filter, deletedAt: null condition, and that no query runs when the lesson list is empty; in src/app/(dashboard)/dashboard/page.tsx lines 33-44, verify aggregate counts use only the scoped progress records. Do not add page-rendering unit-test infrastructure.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/app/`(dashboard)/courses/page.tsx:
- Around line 40-51: Cover the shared scoped-progress query contract with
Playwright page-flow regression tests: in src/app/(dashboard)/courses/page.tsx
lines 40-51, verify the lessonId.in filter, deletedAt: null condition, and that
no query runs when the lesson list is empty; in
src/app/(dashboard)/dashboard/page.tsx lines 33-44, verify aggregate counts use
only the scoped progress records. Do not add page-rendering unit-test
infrastructure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 35203a01-ba56-4233-9d1e-2614960e8dbb
📒 Files selected for processing (2)
src/app/(dashboard)/courses/page.tsxsrc/app/(dashboard)/dashboard/page.tsx
💡 What:
This PR optimizes user-specific
LessonProgressquerying on both/coursesand/dashboardpages by scoping the database query using{ lessonId: { in: allLessonIds } }.🎯 Why:
Previously, the code loaded the user's entire history of progress for all lessons in the database (
where: { userId: user.id }), which leads to bloated database payloads, unnecessary network latency, and high memory consumption on Next.js servers once students build up a larger learning history.📊 Impact:
🔬 Measurement:
Verified that the logic returns identical course completions and progress states while restricting query scope via existing test suites, linters, and type-checks.
PR created automatically by Jules for task 10386170049923415437 started by @projectamazonph
Summary by CodeRabbit