fix: corrected the issue causing split project entries closes #1

This commit is contained in:
Alex Kelly 2021-08-23 17:10:17 -04:00
parent 1c50050a05
commit cdb5799313

View file

@ -2,11 +2,11 @@
""" Get completed tasks from taskwarrior and output a simple report """ """ Get completed tasks from taskwarrior and output a simple report """
import subprocess import subprocess
import json import json
import itertools
import operator
from datetime import date from datetime import date
from dateutil.relativedelta import relativedelta, MO from dateutil.relativedelta import relativedelta, MO
import click import click
import itertools
import operator
__version__ = "0.2.0" __version__ = "0.2.0"
@ -35,16 +35,20 @@ def main(uuid, header):
entries = json.loads(tasks.stdout.decode()) entries = json.loads(tasks.stdout.decode())
output_list = [] output_list = []
project_list = []
if header: if header:
print(f"Reporting from: {last_monday}") print(f"Reporting from: {last_monday}")
for i, g in itertools.groupby(entries, key=operator.itemgetter("project")): for status_projects, status_entries in itertools.groupby(
output_list.append(list(g)) entries, key=operator.itemgetter("project")
for project in output_list: ):
print(f'* {project[0]["project"]}') project_list.append(status_projects)
for entry in project: output_list.append(list(status_entries))
if uuid: for project in project_list:
print(f"* {project}")
for entry in entries:
if entry["project"] == project and uuid:
print(f'\t* {entry["description"]} ({entry["uuid"]})') print(f'\t* {entry["description"]} ({entry["uuid"]})')
else: if entry["project"] == project:
print(f'\t* {entry["description"]}') print(f'\t* {entry["description"]}')