如何使用"github_api"gem从GitHub API v3获得100多个结果?

Art*_*lov 5 pagination rubygems ruby-on-rails github-api

我正在使用GitHub API Gem并尝试获取有关贡献者的添加,删除和提交计数的统计信息.问题是我只得到100个结果,无法访问其他页面.这似乎是一个非常常见的问题,但我找不到答案.

例如,让我们来看看rails/rails repo.有1 990个贡献者:

  repo = Github::Repos.new user: 'rails', repo: 'rails'
  repo.stats.contributors
Run Code Online (Sandbox Code Playgroud)

我得到的是前100个结果.

我试图查询链接头中包含的分页信息.我在rails console中的输出:

irb(main):001:0> repo = Github::Repos.new
=> #<Github::Repos:0xa6941dc *@current_options ommited* >

irb(main):002:0> res = repo.stats.contributors user: 'rails', repo: 'rails'
=> #<Github::ResponseWrapper *@body omitted* >

irb(main):003:0> res.links
=> #<Github::PageLinks:0xa2a966c @next=nil, @last=nil>
Run Code Online (Sandbox Code Playgroud)

没有.

传递auto_pagination选项对我来说没有任何改变.

我错过了什么?

Art*_*lov 10

我尝试了很多东西,最终得到了底层的GitHub API HTTP方法.例如:

curl https://api.github.com/repos/rails/rails/stats/contributors 
Run Code Online (Sandbox Code Playgroud)

一无所获.所以,我发了一封电子邮件给GitHub支持.以下是Wynn Netherland的答案:

感谢您的联系.这种特殊方法不支持分页,因此我们有效地将贡献者数据限制为100,如您所发现的那样.我不能保证是否/何时我们能够显示更多数据,因为它对我们来说是一种昂贵的终点.密切关注API开发人员文档以获取更新.

谢谢永利.因此,GitHub Repo Statistics API不支持分页.没有办法获得超过100个结果的贡献者列表.