我如何从GitHub API v3使用“github_api”获得100多个结果?宝石? [英] How can I get more than 100 results from GitHub API v3 using "github_api" gem?

查看:320
本文介绍了我如何从GitHub API v3使用“github_api”获得100多个结果?宝石?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



例如,让我们看看rails / rails回购。有1 990名贡献者:

  repo = Github :: Repos.new用户:'rails',repo:'rails'
repo.stats.contributors

我得到的是前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用户:'rails',repo:'rails'
=> #< Github :: ResponseWrapper * @ body ignored *>

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支持。以下是永利荷兰的答案:


感谢您的联系。这种特殊的方法不支持
分页,因此我们正在有效地将贡献者数据限制为100
,正如您发现的那样。我无法承诺,如果我们能够在这一张上显示更多的数据,那么这对我们来说是一个昂贵的终端。
请关注API开发人员文档以获取更新。


感谢Wynn。所以,GitHub Repo Statistics API不支持分页。无法获得超过100个结果的贡献者列表。


I'm using GitHub API Gem and trying to get statistics about contributors's additions, deletions, and commit counts. The problem is that I get only 100 results and can't get access to other pages. It seems to be very common question but I couldn't find the answer.

For instance, let's look at rails/rails repo. There's 1 990 contributors:

  repo = Github::Repos.new user: 'rails', repo: 'rails'
  repo.stats.contributors

What I get is first 100 results.

I tried to query pagination information included in the link header. My output in 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>

Nothing.

Passing auto_pagination option doesn't change anything for me.

What am I missing?

解决方案

I tried many things and ended up with the underlying GitHub API HTTP methods. For example:

curl https://api.github.com/repos/rails/rails/stats/contributors 

Got nothing. So, I dropped an e-mail to GitHub Support. Here's the answer from 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.

Thanks Wynn. So, GitHub Repo Statistics API isn't supporting pagination. There is no way to get contributors list with more than 100 results.

这篇关于我如何从GitHub API v3使用“github_api”获得100多个结果?宝石?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆