fix: parallelize analytics queries with Promise.all to prevent 504 timeouts#243
Conversation
|
@sachin-mahato25 is attempting to deploy a commit to the Karan Mani Tripathi 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @knoxiboy! Fixed this by wrapping all 7 independent queries in PR has been submitted for your review. Looking forward to your feedback! 🙏 |
There was a problem hiding this comment.
Technical Review
Hi @sachin-mahato25! Thank you for your contribution to DoubtDesk.
The code changes look good. Before we can complete the technical review, approve, and merge this pull request, we have one final requirement for all contributors: Please star the DoubtDesk repository.
Once you have starred the repository, please drop a comment here saying "done" (or we will automatically detect it) and we will proceed with approving and merging your PR. Thank you.
|
@knoxiboy Done! ⭐ I have starred the DoubtDesk repository. Thank you for reviewing my contribution. |
Closes #223
Problem
The analytics endpoint ran 7 database queries sequentially, causing
the Vercel serverless function to exceed the 10-second timeout limit
for classrooms with 50+ users, resulting in 504 Gateway Timeout errors.
Fix
Wrapped all 7 independent queries in
Promise.all()so they executein parallel. Response time is now determined by the slowest single
query instead of the sum of all queries.
Changes
app/api/analytics/route.ts— parallelized all analytics queries