【问题标题】:Jira - Get issue rating via REST APIJira - 通过 REST API 获取问题评级
【发布时间】:2015-10-21 18:40:20
【问题描述】:

我正在尝试通过 REST 获取 Jira ID 的排名:

这是我发送的 GET 请求:

JIRA-HOST/rest/agile/1.0/issue/MyIssue

我得到了key:customfield_10690,这是评分字段,但是这个字段的值是不可读和不可解析的,我得到的值是:"customfield_10690":"0|i1qu83:"

我能做什么?

【问题讨论】:

    标签: rest jira jira-rest-api jira-agile


    【解决方案1】:

    评分系统是一系列图像吗?比如明星什么的?也许 jira 正试图将图像作为文本发送给您,而那将变成无法打印的东西。

    如果是这种情况,我认为您唯一的选择是: 1.将评分系统更改为数字 2. 如果值一致,请进行映射,以便您可以将“0|i1qu83:”映射到对您的代码有意义的评级。

    【讨论】:

      【解决方案2】:

      您看到的值是lexorank token

      如果您需要数字排名(例如 100 中的第 15 位),您可能希望使用 JQL(他们的有限查询语言)通过 JIRA 搜索端点获取问题的总列表,并枚举结果或搜索问题您需要在增加或更新某些排名时按键。如果您的查询返回多个结果,性能很重要,并且您只需要一个问题,您可能需要使用更智能的搜索,例如 binary search

      这是一个使用node client 的粗略示例:

      import jiraAPI from 'jira-client'
      
      const jira = new jiraAPI({
        protocol: 'https',
        host: process.env['JIRA_HOST'],
        username: process.env['JIRA_USERNAME'],
        password: process.env['JIRA_PASSWORD'],
        apiVersion: '2',
        strictSSL: true,
        timeout: 30000, // 30s
      })
      
      const JQL = 'project = "your-project" AND status IN ("To Do", "In Progress", "Blocked") order by status desc, Rank asc'
      
      const FIELDS = ['key', 'priority', 'status', 'summary', 'labels', 'assignee']
      
      const formatIssue = ({ issue: { key, fields = {} }, rank = 0, total = 0 }) => ({
        key,
        rank,
        total,
        priority: fields.priority.name,
        status: fields.status.name,
        summary: fields.summary,
        assignee: fields.assignee ? fields.assignee.displayName : null,
        labels: fields.labels
      })
      
      async function* issueGenerator ({ offset = 0, limit = 100 }) {
        for (let max = 1; offset < max; offset += limit) {
          const { total = 0, maxResults = 0, startAt = 0, issues = [] } = await jira.searchJira(JQL, {
            startAt: offset,
            maxResults: limit,
            fields: FIELDS
          })
      
          max = total
          limit = maxResults
          offset = startAt
      
          for (let i = 0, len = issues.length; i < len; i++) {
            yield formatIssue({ issue: issues[i], rank: offset + i + 1, total })
          }
        }
      }
      
      
      async function fetchIssuesWithLabel (label) {
        const issueIterator = issueGenerator({ offset: 0, limit: 100 })
        const teamIssues = []
      
        for await (const issue of issueIterator) {
          if (issue.labels.includes(label)) {
            teamIssues.push(issue)
          }
        }
      
        return teamIssues
      }
      
      fetchIssuesWithLabel('bug').then(result => console.log(result))
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-12-21
        • 2015-09-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-22
        • 1970-01-01
        相关资源
        最近更新 更多