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

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

问题描述

我正在使用 GitHub API Gem 并尝试 获取贡献者的增删改查统计计数.问题是我只得到 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.

例如,让我们看看 rails/rails 存储库.有 1 990 位贡献者:

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

我得到的是前 100 个结果.

What I get is first 100 results.

我试图查询链接标题中包含的分页信息.我在 rails 控制台中的输出:

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>

没什么.

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

Passing auto_pagination option doesn't change anything for me.

我错过了什么?

推荐答案

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

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 

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

Got nothing. So, I dropped an e-mail to GitHub Support. Here's the answer from Wynn Netherland:

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

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 个结果的贡献者列表.

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"从 GitHub API v3 获得 100 多个结果?宝石?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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