Commit 75423dbd authored by Thomas Lotze's avatar Thomas Lotze

re #2: have month default to current month, include time range in report

parent 2bc04131
......@@ -20,6 +20,8 @@ import click
@click.option(
'--month',
help='Filter for month (yyyy-mm)',
default=date.today().isoformat().rsplit('-', 1)[0],
show_default=True,
)
@click.option(
'--start',
......@@ -50,17 +52,19 @@ def cli(url, token, month, start, end, project, username, csv):
first = date.fromisoformat(first)
_, last = monthrange(first.year, first.month)
end = '{}-{}'.format(month, last)
filter = dict(
start=start,
end=end,
project=project,
username=username,
)
entries = fetch(url, token, filter)
if csv:
report_csv(entries, csv)
report_csv(entries, csv, filter)
else:
report(entries)
report(entries, filter)
def main():
......
......@@ -4,7 +4,7 @@ from gitlab.v4.objects import ProjectMergeRequest
import csv
def report_csv(entries_by_project, csvpath):
def report_csv(entries_by_project, csvpath, filter):
"""Print a report and create a CSV file.
"""
with open(csvpath, 'w', newline='') as csvfile:
......@@ -25,12 +25,15 @@ def report_csv(entries_by_project, csvpath):
'Hours': hours,
})
report(entries_by_project, writerow)
report(entries_by_project, filter, writerow)
def report(entries_by_project, writerow=lambda *args: None):
def report(entries_by_project, filter, writerow=lambda *args: None):
"""Aggregate unordered sequences of time tracking entries into a report.
"""
print('from {} to {}'.format(filter['start'], filter['end']))
print()
total = sum(report_project(project, entries, writerow)
for project, entries in entries_by_project)
......
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