Skip to content

⚡ Bolt: [performance improvement] Concurrent data fetching in classroom APIs#143

Open
xb1g wants to merge 1 commit into
mainfrom
bolt/classroom-api-optimization-9959380812066159046
Open

⚡ Bolt: [performance improvement] Concurrent data fetching in classroom APIs#143
xb1g wants to merge 1 commit into
mainfrom
bolt/classroom-api-optimization-9959380812066159046

Conversation

@xb1g

@xb1g xb1g commented Mar 22, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Refactored multiple sequential Supabase database queries into concurrent queries using Promise.all in two API endpoints: app/api/classrooms/route.ts and app/api/classrooms/[id]/stats/route.ts.

🎯 Why: To eliminate "waterfall" network requests. In Node.js serverless environments, waiting for independent queries sequentially artificially increases latency. By firing them concurrently, we reduce the total response time to the duration of the slowest single query.

📊 Impact: Expect a noticeable reduction in latency when fetching the user's classroom list and classroom statistics dashboard. The total database wait time in these handlers is roughly cut in half (or a third).

🔬 Measurement: Verify the improvement by timing the GET requests to /api/classrooms and /api/classrooms/[id]/stats before and after this change under typical network conditions. Ensure the test suite continues to pass and no data is missing.


PR created automatically by Jules for task 9959380812066159046 started by @xb1g

Co-authored-by: xb1g <70068561+xb1g@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.

@vercel

vercel Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
pseed Error Error Mar 22, 2026 3:56am

Request Review

@xb1g xb1g force-pushed the bolt/classroom-api-optimization-9959380812066159046 branch from 3f92abb to 345e993 Compare May 11, 2026 17:28
Copilot AI review requested due to automatic review settings May 11, 2026 17:28
@vercel

vercel Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Unable to deploy a commit from a private repository on your GitHub organization to the wachaa1319's projects team on Vercel, which is currently on the Hobby plan. In order to deploy, you can:

  • Make your repository public or
  • Upgrade to Pro. A Pro subscription is required to deploy from a private organization repository.

To read more about collaboration on Vercel, click here.

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.

Pull request overview

Refactors classroom-related Next.js API route handlers to fetch independent Supabase queries concurrently, reducing request latency for the classroom list and classroom stats dashboard endpoints.

Changes:

  • /api/classrooms: fetch classroom details and membership rows in parallel and compute per-classroom member/role counts from the combined results.
  • /api/classrooms/[id]/stats: fetch membership roles, active assignment count, and enrollment progress concurrently to avoid sequential (“waterfall”) DB waits.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
app/api/classrooms/route.ts Uses Promise.all to fetch classroom records and membership rows concurrently, then derives member/role counts for response shaping.
app/api/classrooms/[id]/stats/route.ts Uses Promise.all to fetch membership role data, active assignment count, and enrollment progress concurrently before computing stats.

@xb1g xb1g force-pushed the bolt/classroom-api-optimization-9959380812066159046 branch from 345e993 to de3aa88 Compare May 11, 2026 17:37
@xb1g xb1g force-pushed the bolt/classroom-api-optimization-9959380812066159046 branch from de3aa88 to 2d5ec3c Compare May 11, 2026 17:39
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 11, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
web 2d5ec3c May 11 2026, 06:39 PM

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