GitHub API - 如何从私有 GitHub 存储库获取“问题数量”到 Google Sheets?

问题描述 投票:0回答:2

我正在尝试掌握 GitHub API。通过执行以下操作,我从 API 中获得了详细的问题列表:

function myFunction() { var url = 'https://api.github.com/repos/repo/subrepo/issues';
var response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true});
Logger.log(response);
}

但这只是控制台日志 - 似乎无法让我看到有多少问题。有没有获取“未决问题总数”或“已关闭问题”的 GitHub API 方法?

我理想地希望将数据放入 Google 表格并将其输入 Geckoboard,但首先我必须知道我实际上可以将所需的数据放入日志中,然后我可以开始研究如何将其放入表格中.

PS 一个具体细节:存储库是私有的 - 并且搜索问题似乎无法访问 ?access_token=mytoken

github google-apps-script google-sheets github-api
2个回答
3
投票

您可以使用 GitHub API 的搜索功能来获取您想要的问题。例如,要从打开的“repo/subrepo”中查找问题,您可以使用 -

https://api.github.com/search/issues?q=repo:repo/subrepo+state:open

注意如果您的存储库是私有的,您将需要创建一个access_token并在查询中提供它,如下所示:

https://api.github.com/search/issues?q=repo:repo/subrepo+state:open&access_token=yourToken
.

在常规查询中,?access_token=yourToken 可以使用,但在此类搜索中语法必须为 &access_token=yourToken

在 JSON 响应中,字段“total_count”为您提供搜索中找到的问题数。请参阅:https://help.github.com/articles/searching-issues/


0
投票

仅适用于像我这样从 Google 来到这里尝试获取公共存储库问题数量的人:

对于 PUBLIC 存储库或配置访问令牌时, 您可以使用公式获得大量问题:

未解决的问题:

=IMPORTXML($F2, "//span[text()='Issues']/following-sibling::span[@class='Counter']/text()")

已解决的问题:

=VALUE(REGEXEXTRACT(SUBSTITUTE( INDEX(IMPORTXML($F2&"/issues", "//a[contains(@href, 'is%3Aclosed')]/text()"), 2, 1)  , ",", ""), "\d+"))

其中 F2 包含如下 URL: https://github.com/pimcore/pimcorehttps://github.com/sulu/sulu

© www.soinside.com 2019 - 2024. All rights reserved.