Update PR volume counting from GitHub Archive to GitHub Search API#43
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Search API–backed implementation for computing PR volume counts (as an alternative to the existing BigQuery/GH Archive approach) and wires it into the CLI so volumes can be fetched without BigQuery.
Changes:
- Added Search API querying helpers (
_search_api_count,_date_range,_weekly_chunks) and a newfetch_pr_volumes_search_apipipeline path. - Updated the
volumesCLI subcommand to support--source {bq,search-api}(defaultsearch-api) and--weekly. - Expanded unit tests to cover the new date helpers and Search API count behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| online/etl/pipeline/volumes.py | Adds Search API volume counting, retry logic, and date chunking utilities. |
| online/etl/main.py | Extends volumes CLI to select data source and enable weekly chunking. |
| online/etl/tests/test_volumes.py | Adds tests for date range/chunking and Search API counting behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+168
to
+176
| if resp.status_code == 403: | ||
| retry_after = resp.headers.get("Retry-After") | ||
| wait = int(retry_after) if retry_after else 60 | ||
| logger.warning( | ||
| f"Search API rate limited for {bot_username}, " | ||
| f"waiting {wait}s (attempt {attempt + 1}/3)" | ||
| ) | ||
| await asyncio.sleep(wait) | ||
| continue |
Comment on lines
+181
to
+196
| @pytest.mark.asyncio | ||
| async def test_search_api_count_retries_on_rate_limit() -> None: | ||
| rate_limited = MagicMock(spec=httpx.Response) | ||
| rate_limited.status_code = 403 | ||
| rate_limited.headers = {"Retry-After": "1"} | ||
|
|
||
| success = MagicMock(spec=httpx.Response) | ||
| success.status_code = 200 | ||
| success.json.return_value = {"total_count": 42} | ||
|
|
||
| mock_client = AsyncMock(spec=httpx.AsyncClient) | ||
| mock_client.get.side_effect = [rate_limited, success] | ||
|
|
||
| result = await _search_api_count(mock_client, "test[bot]", "2026-06-15") | ||
| assert result == 42 | ||
| assert mock_client.get.call_count == 2 |
zverianskii
approved these changes
Jun 24, 2026
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.
GitHub Archive (which mirrors the public Events API) structurally undercounts GitHub App review activity. Comparing a 2-week window (Jun 3–17), GH Archive captured only ~8–25% of actual PR review volume depending on the bot.
This PR adds a
--source search-apioption (now the default) to thevolumescommand, usingreviewed-by:<bot> type:prqueries.