Commit abd3f339 authored by Thomas Lotze's avatar Thomas Lotze
Browse files

re #19: collect time from merge requests

parent af555b8c
......@@ -43,9 +43,11 @@ def fetch(url, token, filter):
issues = project.issues.list(all=True)
merge_requests = project.mergerequests.list(all=True)
for item in issues:
for item in issues + merge_requests:
entries = defaultdict(float)
for author, date, seconds in fetch_times(item):
if filter['username'] not in (author, None):
from collections import defaultdict
from gitlab.v4.objects import ProjectIssue
from gitlab.v4.objects import ProjectMergeRequest
def report(entries):
......@@ -11,7 +13,9 @@ def report(entries):
for entry in entries:
project = entry['project'].name
item = entry['item']
item = (item.iid, item)
item = ([ProjectIssue, ProjectMergeRequest].index(type(item)),
author = entry['author']
times[project][item][author].append((entry['date'], entry['hours']))
totals_by_project[project] += entry['hours']
......@@ -22,9 +26,12 @@ def report(entries):
for project, times_by_item in sorted(times.items()):
print('{}: {:.2f}'.format(project, totals_by_project[project]))
for (_, item), times_by_author in sorted(times_by_item.items()):
print('{}#{}: {:.2f} ({})'.format(
4*' ', item.iid, totals_by_item[item], item.title))
for (_, _, item), times_by_author in sorted(times_by_item.items()):
print('{}{}: {:.2f} ({})'.format(
4*' ',
for author, time_log in sorted(times_by_author.items()):
for date, hours in sorted(time_log):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment