要计算JIRA中的评论数量,您可以使用JIRA的REST API。以下是一个示例步骤:
https://your-jira-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment
{issueIdOrKey}
替换为您要查询的JIRA问题的ID或键。requests
库来执行此操作:import requests
url = "https://your-jira-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment"
headers = {"Authorization": "Bearer <your-access-token>"}
response = requests.get(url, headers=headers)
total
的属性,表示评论数量。例如:{
"startAt": 0,
"maxResults": 50,
"total": 2,
"comments": [
{
"self": "https://your-jira-domain.atlassian.net/rest/api/3/issue/10010/comment/10000",
"id": "10000",
"author": {
"self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
"accountId": "123456:abcdef",
"displayName": "Your Name"
},
"body": "This is a comment.",
"updateAuthor": {
"self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
"accountId": "123456:abcdef",
"displayName": "Your Name"
},
"created": "2022-01-01T00:00:00.000+0000",
"updated": "2022-01-01T00:00:00.000+0000",
"visibility": {
"type": "role",
"value": "Administrators"
}
},
{
"self": "https://your-jira-domain.atlassian.net/rest/api/3/issue/10010/comment/10001",
"id": "10001",
"author": {
"self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
"accountId": "123456:abcdef",
"displayName": "Your Name"
},
"body": "This is another comment.",
"updateAuthor": {
"self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
"accountId": "123456:abcdef",
"displayName": "Your Name"
},
"created": "2022-01-02T00:00:00.000+0000",
"updated": "2022-01-02T00:00:00.000+0000",
"visibility": {
"type": "role",
"value": "Administrators"
}
}
]
}
在这个例子中,评论数量是2。
请注意,这只是一个示例,您可能需要根据您的具体需求进行调整。
领取专属 10元无门槛券
手把手带您无忧上云