diff --git a/README.md b/README.md index f267bcb..b461316 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ +task-recurring-delete +--------------------- Delete all overdue, recurring and duplicate taskwarrior tasks and keep only the first of a kind. -Needs the taskw Python bindings to run. +task-recurring-postpone +----------------------- +Postpone recurring task dupes to tomorrow and keep only two per parent task. -This is a workaround for this issue: https://bug.tasktools.org/browse/TW-1314 + +
+ +Need the taskw Python bindings to run. These are workarounds for this issue: +https://bug.tasktools.org/browse/TW-1314. diff --git a/task-recurring-postpone b/task-recurring-postpone new file mode 100755 index 0000000..3b55a3b --- /dev/null +++ b/task-recurring-postpone @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +import datetime +from taskw import TaskWarrior +from pprint import pprint +from operator import itemgetter +from itertools import groupby + + +w = TaskWarrior(marshal=True) +tasks = w.load_tasks()["pending"] +tasks = list(filter(lambda t: t.get("status") == "pending", tasks)) + +# Recurring tasks have a "parent" +tasks = list(filter(lambda t: t.get("parent") is not None, tasks)) + +for k, g in groupby(sorted(tasks, key=itemgetter("parent")), key=itemgetter("parent")): + # Postpone all but the two most urgent tasks + to_postpone = sorted(g, key=itemgetter("urgency"))[:-2] + if not to_postpone: + continue + + print(f"Postponing {len(to_postpone)}x {to_postpone[0]['description']}") + for t in to_postpone: + t["status"] = "waiting" + t["wait"] = datetime.datetime.combine(datetime.date.today(), datetime.datetime.min.time()) \ + + datetime.timedelta(days=1) + w.task_update(t)