Skip to content

feat: make parallel API requests when applicable#436

Merged
ECWireless merged 3 commits intomainfrom
331-switch-to-parallel-network-requests
Dec 12, 2025
Merged

feat: make parallel API requests when applicable#436
ECWireless merged 3 commits intomainfrom
331-switch-to-parallel-network-requests

Conversation

@ECWireless
Copy link
Collaborator

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

Code correctness and clarity

  • Improved error handling for the newly batched HTTP requests, ensuring that failures for each endpoint are logged and surfaced with clear error messages. (pages/api/score/[address].tsxL92-R108)
  • Refactored the createMetricsObject function 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

Copilot AI review requested due to automatic review settings December 11, 2025 04:35
@ECWireless ECWireless linked an issue Dec 11, 2025 that may be closed by this pull request
@vercel
Copy link
Contributor

vercel bot commented Dec 11, 2025

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

Project Deployment Preview Comments Updated (UTC)
explorer-arbitrum-one Ready Ready Preview Comment Dec 11, 2025 5:42am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.all in the score endpoint
  • Replaced sequential blockchain contract calls with a single multicall in the pending-stake endpoint
  • Refactored the createMetricsObject function 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.

@github-project-automation github-project-automation bot moved this from Backlog to Todo in Explorer Revamp Dec 11, 2025
@ECWireless ECWireless merged commit 8b9b485 into main Dec 12, 2025
4 checks passed
@ECWireless ECWireless deleted the 331-switch-to-parallel-network-requests branch December 12, 2025 16:40
@github-project-automation github-project-automation bot moved this from Todo to Done in Explorer Revamp Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

Switch to parallel network requests

3 participants