我如何查看使用GitHub GraphQL API在项目中的列之间移动了问题?

时间:2018-07-11 21:17:16

标签: github graphql github-api github-graphql github-projects

我想使用GitHub GraphQL API确定何时卡片在GitHub Project Board中从一列移到另一列。

我可以使用类似这样的查询列出项目委员会中的所有问题(例如Twitter Bootstrap):

{
  organization(login: "twbs") {
    repository(name: "bootstrap") {
      project(number: 4) {
        columns(first: 5) {
          nodes {
            name
            cards(first: 10) {
              nodes {
                content {
                  __typename
                  ... on Issue {
                    title
                    url
                    timeline(first: 10) {
                      nodes {
                        __typename
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

many types of events中有IssueTimelineConnection,但是与项目相关的事件不在其中:

...
{
  "content": {
    "__typename": "Issue",
    "title": "Remove inner white border effect on popovers",
    "url": "https://github.com/twbs/bootstrap/issues/23763",
    "timeline": {
      "nodes": [
        {
          "__typename": "RenamedTitleEvent"
        },
        {
          "__typename": "IssueComment"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "IssueComment"
        },
        {
          "__typename": "CrossReferencedEvent"
        },
        {
          "__typename": "CrossReferencedEvent"
        },
        {
          "__typename": "LabeledEvent"
        },
        {
          "__typename": "ClosedEvent"
        },
        {
          "__typename": "CrossReferencedEvent"
        }
      ]
    }
  }
...

我可以看到问题何时在GitHub网页上的各列之间移动:

image

我只是在API中看不到这些事件。这是缺少的功能吗?还有另一种获取此信息的方法吗? (上下文:我想构建一个burndown chart for GitHub Project Boards。)

1 个答案:

答案 0 :(得分:0)

您需要添加项目事件详细信息(https://developer.github.com/v4/previews/#project-event-details)的接受标头问题发布预览(https://developer.github.com/v4/previews/#issues-preview)的接受标头

然后,您可以使用import tensorflow as tf A = ... # B x 3000 x 3 C = ... # B x 4000 s = tf.shape(C) B, cols = s[0], s[1] # Make indices for first dimension idx = tf.tile(tf.expand_dims(tf.range(B, dtype=C.dtype), 1), [1, cols]) # Complete index for gather_nd gather_idx = tf.stack([idx, C], axis=-1) # Gather result result = tf.gather_nd(A, gather_idx) 并运行如下查询:

timelineItems

这将返回:

query {
  repository(owner: "buildo", name: "react-components") {
    issue(number: 1321) {
      timelineItems(first: 10) {
        nodes {
          __typename
        }
      }
    }
  }
}