GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add pagination to search endpoints by alaycock · Pull Request #583 · github-tools/github

Conversation

@alaycock

@alaycock alaycock commented Sep 6, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Changes:

  • Updated the jsdoc to correctly document the Github.search function.
  • If a page option is passed into _requestAllPages, it will only fetch that single page, instead of attempting to fetch all of the pages.
  • Removed the results parameter from _requestAllPages, since that is only meant to be used internally anyway. It's trivial to re-introduce, so let me know if this makes sense to do, since this could break some backwards compatibility if folks are using an unsupported argument.
  • Added a test for pagination, and a new fixture for that test. Fixed a number of other fixtures that didn't seem to have the correct page number.
  • Changed the fixtures to use rawHeader instead of header, since the tests were not paginating. This was introduced when the spec for fixture files changed from nock@7 to nock@8.

Let me know if this is the right approach. I've only run tests for the search endpoints (due to lack of access to the testing repo), so I'm not sure if this is going to introduce errors elsewhere.

Closes #406
This could be a potential solution for #460, although introducing a limit could be an alternate solution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Adam Laycock | Versett
Add pagination to search endpoints
a033c35
alaycock
alaycock commented Sep 6, 2019
View reviewed changes
Comment thread lib/GitHub.js
/**
* Create a new Search wrapper
* @param {string} query - the query to search for
* @param {Search.Params} searchParameters - the query and other search parameters

@alaycock alaycock Sep 6, 2019

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Not sure if jsdoc understands how to reach into other files (Search.js). Let me know if this will be a problem.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
alaycock
alaycock commented Sep 6, 2019
View reviewed changes
Comment thread lib/Requestable.js
if (!options) {
options = {};
}
options.page = parseInt(

@alaycock alaycock Sep 6, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

If someone can clarify this, I would appreciate it.

Why does the page number need to be manually extracted and appended to the options?

nextUrl is being extracted from the headers, wouldn't it have all the options it already needs? Then by calling this._requestAllPages(nextUrl, options, cb, results); the options are being re-added to the url, which results in duplicate parameters in the path, eg:

/search/repositories?q=tetris+language%3Aassembly&sort=stars&order=desc&type=all&per_page=100&page=4&q=tetris+language:assembly&sort=stars&order=desc&type=all&per_page=100&page=4

Although this might just be a workaround for other endpoints, since I have't done exploration into how other endpoints paginate.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Feature Request] Ability to fetch a single page of items in a list

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@alaycock
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.