feat: make parallel API requests when applicable#436
Merged
ECWireless merged 3 commits intomainfrom Dec 12, 2025
Merged
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request optimizes two API endpoints by parallelizing independent requests, reducing overall latency and improving performance. The changes batch HTTP requests and blockchain contract calls that were previously executed sequentially.
Key changes:
- Implemented parallel execution of three HTTP requests using
Promise.allin the score endpoint - Replaced sequential blockchain contract calls with a single
multicallin the pending-stake endpoint - Refactored the
createMetricsObjectfunction for better type safety and code clarity
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pages/api/score/[address].tsx |
Batched three independent HTTP requests (top AI score, metrics, pricing) into a single Promise.all, improved error messages, and refactored createMetricsObject with better typing and variable naming |
pages/api/pending-stake/[address].tsx |
Replaced two sequential readContract calls with a single multicall to fetch pending stake and fees in parallel, reducing blockchain RPC overhead |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Jipperism
approved these changes
Dec 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AI Summary
This pull request improves the efficiency and clarity of two API endpoints by batching contract calls and HTTP requests, and by refining the metrics calculation logic. The most important changes are grouped below:
Performance improvements
pendingStakeandpendingFees) inpages/api/pending-stake/[address].tsxwith a singlemulticall, reducing network overhead and improving response time. (pages/api/pending-stake/[address].tsxL35-R50)top_ai_score,aggregated_stats, andpricingUrl) into a singlePromise.allinpages/api/score/[address].tsx, optimizing data retrieval and reducing latency. (pages/api/score/[address].tsxL64-L82, pages/api/score/[address].tsxL92-R108)Code correctness and clarity
createMetricsObjectfunction to use more precise typing (keyof Metric), clarified variable naming, and streamlined the calculation of regional and global metrics values. (pages/api/score/[address].tsxL117-L140)Minor improvements
topAIScorefield in the combined metrics response. (pages/api/score/[address].tsxL156-R161)