Skip to content

⚡ Bolt: Optimize user lesson progress queries on dashboard and courses pages - #100

Open
projectamazonph wants to merge 1 commit into
mainfrom
bolt-optimize-lesson-progress-query-10386170049923415437
Open

⚡ Bolt: Optimize user lesson progress queries on dashboard and courses pages#100
projectamazonph wants to merge 1 commit into
mainfrom
bolt-optimize-lesson-progress-query-10386170049923415437

Conversation

@projectamazonph

@projectamazonph projectamazonph commented Jul 31, 2026

Copy link
Copy Markdown
Owner

💡 What:
This PR optimizes user-specific LessonProgress querying on both /courses and /dashboard pages 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:

  • Drastically reduces database response payload size.
  • Lowers server memory footprints for users with long-standing activity histories.
  • Makes page load noticeably more efficient and scalable.

🔬 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

  • Bug Fixes
    • Improved lesson progress loading on the Courses and Dashboard pages.
    • Progress now reflects only lessons from published courses and modules, preventing unrelated records from appearing.
    • Pages handle courses without lessons more efficiently and display empty progress correctly.

…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>
@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 31, 2026 14:02

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 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

Lesson progress query scoping

Layer / File(s) Summary
Scope progress loading
src/app/(dashboard)/courses/page.tsx, src/app/(dashboard)/dashboard/page.tsx
Both pages derive lesson IDs from fetched courses, filter progress records by those IDs and the authenticated user, and skip the database query when no lesson IDs exist.

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 and concisely identifies the lesson progress query optimization on the dashboard and courses pages.
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 bolt-optimize-lesson-progress-query-10386170049923415437

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.


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

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

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/app/(dashboard)/courses/page.tsx (1)

40-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover 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 the lessonId.in filter, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d0e0bf and 5d7cadb.

📒 Files selected for processing (2)
  • src/app/(dashboard)/courses/page.tsx
  • src/app/(dashboard)/dashboard/page.tsx

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