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

add some documentation

parent d012f692
......@@ -19,6 +19,9 @@ def parse_action(action):
def fetch(url, token):
"""Yield all relevant time tracking entries, in no particular order.
gitlab = Gitlab(url, token)
projects = gitlab.projects.list(all=True)
......@@ -26,6 +29,16 @@ def fetch(url, token):
issues = project.issues.list(all=True)
for issue in issues:
# Time tracking in Gitlab works like this: For each comment (note)
# containing a time tracking directive, an additional system note
# is created at that time, which either adds or subtracts time for
# an arbitrary date, or removes any previous time spent. Removal
# invalidates any tracking notes prior to its creation. Tracking
# done after the latest removal always applies, regardless of the
# date it applies to. Thus, we need to consider any and all time
# tracking done after the latest removal, which may track time for
# any date, in any order. We do this by iterating through notes
# backwards by creation date until we find a removal note.
notes = issue.notes.list(
all=True, order_by='created_at', sort='desc')
entries = defaultdict(float)
......@@ -2,6 +2,9 @@ from collections import defaultdict
def report(entries):
"""Aggregate an unordered sequence of time tracking entries into a report.
issues = defaultdict(lambda: defaultdict(set))
totals = defaultdict(lambda: defaultdict(float))
for entry in entries:
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