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

add some useful reporting

parent f2fbe1c6
from gitlabtime.fetch import fetch
from import report
import click
......@@ -15,9 +16,8 @@ import click
def cli(url, token):
entries = fetch(url, token)
for entry in entries:
def main():
return cli(auto_envvar_prefix='GITLABTIME')
from collections import defaultdict
def report(entries):
issues = defaultdict(lambda: defaultdict(set))
totals = defaultdict(lambda: defaultdict(float))
for entry in entries:
project = entry['project'].name
author = entry['author']
totals[project][author] += entry['hours']
totals_by_project = {project: sum(data.values())
for project, data in totals.items()}
total = sum(totals_by_project.values())
for project, issues_by_author in sorted(issues.items()):
print('{}: {:.2f}'.format(project, totals_by_project[project]))
totals_by_author = totals[project]
for author, issues in sorted(issues_by_author.items()):
issues = sorted(issues, key=lambda issue: issue.iid)
log = ', '.join('#{}'.format(issue.iid) for issue in issues)
print(' {}: {:.2f} ({})'.format(
author, totals_by_author[author], log))
print('total: {:.2f}'.format(total))
Markdown is supported
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