Skip to content

⚡ Bolt: Optimize user-specific lesson progress database queries#81

Open
projectamazonph wants to merge 1 commit into
mainfrom
fix/optimize-lesson-progress-queries-1258558220005540877
Open

⚡ Bolt: Optimize user-specific lesson progress database queries#81
projectamazonph wants to merge 1 commit into
mainfrom
fix/optimize-lesson-progress-queries-1258558220005540877

Conversation

@projectamazonph

@projectamazonph projectamazonph commented Jul 24, 2026

Copy link
Copy Markdown
Owner

💡 What:
Restricted Prisma queries for LessonProgress on the main dashboard, the course catalog index page, and the course certificate page using lessonId: { in: allLessonIds } rather than querying all progress history for the user.

🎯 Why:
Querying LessonProgress with only userId retrieves 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, and DATABASE_URL="postgresql://localhost:5432/test" pnpm test to verify zero regressions and complete test suite passes.


PR created automatically by Jules for task 1258558220005540877 started by @projectamazonph

Summary by CodeRabbit

  • Bug Fixes
    • Improved course, dashboard, and certificate progress tracking by limiting results to lessons relevant to the current page.
    • Prevented unrelated lesson history from affecting completion and pending-lesson displays.
    • Reduced unnecessary progress data loading, especially when no relevant lessons are available.

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings July 24, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3231de22-b2d1-45f7-a8d7-f609e3604102

📥 Commits

Reviewing files that changed from the base of the PR and between dabee94 and 6cfa639.

📒 Files selected for processing (4)
  • .jules/bolt.md
  • src/app/(dashboard)/courses/[courseSlug]/certificate/page.tsx
  • src/app/(dashboard)/courses/page.tsx
  • src/app/(dashboard)/dashboard/page.tsx

📝 Walkthrough

Walkthrough

Lesson 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.

Changes

Lesson progress query scoping

Layer / File(s) Summary
Scope progress queries across dashboard surfaces
src/app/(dashboard)/dashboard/page.tsx, src/app/(dashboard)/courses/page.tsx, src/app/(dashboard)/courses/[courseSlug]/certificate/page.tsx, .jules/bolt.md
Dashboard, course listing, and certificate pages derive relevant lesson IDs before fetching progress, skip queries when no IDs exist, and document the scoped-query guidance.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: scoping user-specific lesson progress queries to improve performance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 fix/optimize-lesson-progress-queries-1258558220005540877

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants