Fetch pull request counts in batches with limited concurrency #28
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.
Problem
Pull request counts were previously fetched sequentially, which resulted in slow performance for organizations with many repositories. Each repository had to wait for the previous one to complete before starting its API call.
For example, an organization with 100 repositories would make 100 sequential API calls, with each call waiting for the previous one to finish.
Solution
This PR implements batch processing with limited concurrency to significantly improve performance while respecting GitHub API rate limits.
Key Changes
processPullRequestsInBatchesfunction: A new helper function that processes repositories in configurable batches usingPromise.allfor concurrent fetchinggenerateBadgesfunction: Replaced the sequentialforloop with the new batch processing approachImplementation
Before:
After:
The new function processes repositories in chunks of 10, with each chunk processed concurrently:
Performance Impact
Testing
Added 5 comprehensive test cases covering:
All existing tests continue to pass, ensuring backward compatibility.
Closes #18
Original prompt
Fixes #19
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.