Commit 91b7da5d authored by Thomas Lotze's avatar Thomas Lotze

refactor passing of filter options which will only become more numerous

parent be401bd5
......@@ -27,7 +27,12 @@ import click
help='Filter for user name',
)
def cli(url, token, month, project, username):
entries = fetch(url, token, month, project, username)
filter = dict(
month=month,
project=project,
username=username,
)
entries = fetch(url, token, filter)
report(entries)
......
......@@ -23,7 +23,7 @@ def parse_time(time_str):
return float(value_str) * unit
def fetch(url, token, month, project_name, username):
def fetch(url, token, filter):
"""Yield all relevant time tracking entries, in no particular order.
"""
......@@ -39,7 +39,7 @@ def fetch(url, token, month, project_name, username):
# clever and optimise here, even if this results in a full-database scan.
# Let's see whether we'll be forced to optimise by production data.
for project in projects:
if project_name and project.name != project_name:
if filter['project'] not in (project.name, None):
continue
issues = project.issues.list(all=True)
......@@ -65,7 +65,7 @@ def fetch(url, token, month, project_name, username):
if note.body == 'removed time spent':
break
if username and note.author['username'] != username:
if filter['username'] not in (note.author['username'], None):
continue
sep = ' of time spent at '
......@@ -73,7 +73,7 @@ def fetch(url, token, month, project_name, username):
if _ != sep:
continue
if month and not date.startswith(month):
if not date.startswith(filter['month'] or ''):
continue
seconds = parse_action(action)
......
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