⚡ Bolt: Optimize user-specific lesson progress database queries#81
⚡ Bolt: Optimize user-specific lesson progress database queries#81projectamazonph wants to merge 1 commit into
Conversation
Scope user-specific LessonProgress queries to relevant lesson IDs on the dashboard, course index, and course certificate pages. This prevents fetching the user's entire progress history, greatly reducing the database payload and memory footprint as the user progress history grows. 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughLesson progress queries on the dashboard, courses index, and certificate pages are now filtered to lesson IDs loaded for the current page. Empty lesson sets skip the database query, and a Bolt journal entry documents the scoping pattern. 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. Comment |
💡 What:
Restricted Prisma queries for
LessonProgresson the main dashboard, the course catalog index page, and the course certificate page usinglessonId: { in: allLessonIds }rather than querying all progress history for the user.🎯 Why:
Querying
LessonProgresswith onlyuserIdretrieves the student's entire history of completed and in-progress lessons. As course curricula change or students complete more courses, this causes bloated database payloads and high memory usage. Scoping these queries to only the lesson IDs belonging to the active published courses/lessons in view guarantees high performance and keeps resource utilization minimal.📊 Impact:
Limits database payload size and memory consumption from O(H) (user's entire completion history) to O(K) (active/published context size).
🔬 Measurement:
Run
pnpm typecheck,pnpm lint, andDATABASE_URL="postgresql://localhost:5432/test" pnpm testto verify zero regressions and complete test suite passes.PR created automatically by Jules for task 1258558220005540877 started by @projectamazonph
Summary by CodeRabbit