Fix pagination termination logic and extract max pages constant#23
Merged
Merged
Conversation
Co-authored-by: kertal <463851+kertal@users.noreply.github.com>
Deploying git-vegas with
|
| Latest commit: |
8f0d528
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a564344a.git-vegas.pages.dev |
| Branch Preview URL: | https://copilot-sub-pr-21.git-vegas.pages.dev |
Copilot
AI
changed the title
[WIP] Add pagination support for fetching GitHub issues
Fix pagination termination logic and extract max pages constant
Jan 10, 2026
kertal
marked this pull request as ready for review
January 10, 2026 22:44
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.
Addresses two issues in the GitHub search pagination implementation:
Issue 1: Incorrect pagination termination
The condition
page * perPage >= totalCountfails whentotalCountis exactly divisible byperPage. For 200 items withperPage=100, after fetching page 2, the condition2 * 100 >= 200stops pagination correctly, but the logic was comparing against the wrong accumulator (allItems.length, which includes deduplicated items across all queries) instead of items fetched for the current query.Changes:
itemsFetchedForQuerycounter that accumulates items from the API response before deduplicationpage * perPage >= totalCount || items.length < perPagetoitems.length < perPage || itemsFetchedForQuery >= totalCountmaxPages = 10to module-levelGITHUB_SEARCH_API_MAX_PAGESinsettings.tsfor consistency with other API constantsThe fix ensures accurate pagination for edge cases where the total count is exactly divisible by the page size.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.