我正在使用 GitHub API Gem并试图 get statistics about contributors's additions, deletions, and commit counts .问题是我只得到 100 个结果并且无法访问其他页面。这似乎是一个很常见的问题,但我找不到答案。
例如,让我们看看 rails/rails repo。有 1 990 名贡献者:
repo = Github::Repos.new user: 'rails', repo: 'rails'
repo.stats.contributors
我得到的是前 100 个结果。
我试图查询链接标题中包含的分页信息。我在 rails 控制台中的输出:
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>
没有。
路过
auto_pagination
选项对我没有任何改变。我错过了什么?
最佳答案
我尝试了很多东西,最终得到了底层的 GitHub API HTTP 方法。例如:
curl https://api.github.com/repos/rails/rails/stats/contributors
一无所获。所以,我给 GitHub 支持发了一封电子邮件。这是来自 Wynn Netherland 的答案:
Thanks for getting in touch. That particular method doesn't support pagination, so we're effectively capping the contributors data to 100 as you've discovered. I can't promise if/when we'll be able to show more data on that one since it's sort of an expensive endpoint for us. Keep an eye on the API developer docs for updates.
谢谢永利。因此,GitHub Repo Statistics API 不支持分页。无法获得超过 100 个结果的贡献者列表。
关于ruby-on-rails - 如何使用 "github_api"gem 从 GitHub API v3 获得 100 多个结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18148490/