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

标签 ruby-on-rails pagination rubygems github-api

我正在使用 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/

相关文章:

ruby-on-rails - 无法使用 zeus 的 parallel_tests 创建并行数据库

ruby-on-rails - 如何在 [а-я] 正则表达式字符间隔中包含 ё

mysql - Laravel 为 DB::raw 查询启用分页

ruby - 安装 gem dm-mysql-adapter 时出现 "undefined method ` split'"

ruby-on-rails - 每当 gem 不自动运行?

ruby-on-rails - 光纤局部变量与线程局部变量

ruby-on-rails - savon httperror 302 Rails 3.2

python - Django:分页器 + 原始 SQL 查询

pagination - 获取客户端上的集合大小,而不订阅整个集合

ruby-on-rails - 在 ruby​​ 2.0.0p247 上安装 ruby​​-debug-base 时出错