如何在Gitlab中获得总时间?

Ven*_*ono 10 gitlab gitlab-ce

有没有办法通过时间跟踪/spend 斜杠命令获得用户花费的所有问题的总时间花费?

使用API​​的时间跟踪统计数据只获得少量数据:https://docs.gitlab.com/ce/api/issues.html#get-time-tracking-stats

Gitlab CE 9.1.4

mnv*_*mnv 6

正如我所见,可以从 API v3 解析注释并计算总数。

例如,

https://gitlab.com/api/v3/projects/:id/issues/:issue_id/notes?private_token=your_token

{
  id: 73113225,
  body: "added 1h of time spent at 2018-05-15",
  attachment: null,
  author: {
    ...
    username: "mnvxxx",
  },
  ...
}
Run Code Online (Sandbox Code Playgroud)

更多信息:https : //docs.gitlab.com/ee/api/notes.html

更新

目前我已经创建了用于计算每个贡献者花费的时间的工具。我希望它会有所帮助:

https://github.com/zubride/gitpab


Jos*_*ema 6

这是一个适用于 API v4 的非常简单的 Python 脚本:

import requests

API_KEY = ""  # Enter your API key here
BASE_URL = "https://{{enter gitlab url here}}/api/v4/"

item_counter = 0
total_seconds = 0

for i in range(1, 57):  # manually set range of issues here. All issues doesn't work well.
    issue = requests.get(BASE_URL + 'projects/2/issues/' + str(i) + '/time_stats')
    total_seconds += issue.json()['total_time_spent']
    item_counter += 1

print("Hours on all issues: %.2f" % float((total_seconds / 60) / 60))
print("Total issues: " + str(item_counter))
Run Code Online (Sandbox Code Playgroud)

我发这个帖子是因为这是在谷歌上出现的第一个答案,而且真的没有找到任何其他现成的解决方案。