5

根据我有限的搜索,似乎 GraphQL 只能支持相等过滤。所以,

是否可以使用以下过滤条件进行 Github GraphQL 搜索,

  • 星星 > 10
  • 叉 > 3
  • 总提交 >= 5
  • 总问题 >= 1
  • 未解决的问题 <= 60
  • 大小 > 2k
  • 得分 > 5
  • 最后一次更新是一年内

即,过滤将所有上述条件。可能吗?

4

2 回答 2

6

查询存储库时,您只能对列表中的特定数量的字段应用过滤器:

  • 星数
  • 叉数
  • 尺寸
  • 最后更新

尽管您无法在查询过滤器中指定它们,但您可以在查询中包含其他字段并验证客户端应用程序中的值:

  • 问题总数
  • 未解决问题的数量

虽然理论上,您还可以查询提交次数,应用您的特定参数参数,该查询返回服务器错误,它很可能超时。因此,这些行被注释掉了。

这是 GraphQL 查询:

query {
  search(
    type:REPOSITORY, 
    query: """
      stars:>10
      forks:>3
      size:>2000
      pushed:>=2018-08-08
    """,
    last: 100
  ) {
    repos: edges {
      repo: node {
        ... on Repository {
          url

          allIssues: issues {
            totalCount
          }
          openIssues: issues(states:OPEN) {
            totalCount
          }

          # commitsCount: object(expression: "master") {
          #   ... on Commit {
          #      history {
          #       totalCount
          #     }
          #   }
          # }
        }
      }
    }
  }
}

存储库查询的规范可以在这里找到:https ://help.github.com/en/articles/searching-for-repositories#search-by-repository-size

于 2019-08-08T21:32:22.593 回答
1

这不是一个答案,而是我迄今为止收集的内容的更新。

  • 根据“为 Github GraphQL 搜索选择 * ”,并非所有上述条件都可能在存储库边缘可用。即,“总提交”、“未解决的问题”和“分数”可能不可用。

  • 问题的目的显然是找到有价值的存储库并清除低质量的存储库。我在这里收集了所有可能有助于此类评估的可用字段。

截至 2018-03-18 的副本:

query SearchMostTop10Star($queryString: String!, $number_of_repos:Int!) {
  search(query: $queryString, type: REPOSITORY, first: $number_of_repos) {
    repositoryCount
    edges {
      node {
        ... on Repository {
          name
          url
          description
#         shortDescriptionHTML
          repositoryTopics(first: 12) {nodes {topic {name}}}
          primaryLanguage {name}
          languages(first: 3) { nodes {name} }
          releases {totalCount}
          forkCount
          pullRequests {totalCount}
          stargazers {totalCount}
          issues {totalCount}
          createdAt
          pushedAt
          updatedAt
        }
      }
    }
  }
}
variables {
  "queryString": "language:JavaScript stars:>10000", 
  "number_of_repos": 3 
}

任何人都可以按照这里尝试。

于 2018-03-18T21:46:50.697 回答