β‘ perf: Optimize Leaderboard API to run database queries concurrently#5
β‘ perf: Optimize Leaderboard API to run database queries concurrently#5Ap-0007 wants to merge 1 commit into
Conversation
Refactor `app/api/leaderboard/route.ts` to use `Promise.all` for fetching the "top by commits" and "top by streak" data. This avoids sequential database queries, effectively reducing the endpoint response time. Co-authored-by: Ap-0007 <200978133+Ap-0007@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. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
π‘ What: The optimization uses
Promise.allin the leaderboard API route to execute the "top by commits" and "top by streak" Supabase queries simultaneously rather than waiting for the first one to finish before starting the second.π― Why: The two queries do not depend on each other. By executing them concurrently, the total network roundtrip time is drastically reduced, allowing the endpoint to return data faster.
π Measured Improvement: We created a benchmark script
benchmark.jsto simulate the network and DB latency (~150ms per query). Running the benchmark established:This translates to a direct speed-up in the endpoint roughly proportional to halving the database/network wait time.
PR created automatically by Jules for task 11030325638097154628 started by @Ap-0007