From b8c3c28bcd489086eaa1b32f31e51ae66e891458 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 9 Jun 2020 13:18:07 +1000 Subject: [PATCH] List only tasks that are leaves on the task tree --- src/pyelephant.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pyelephant.py b/src/pyelephant.py index b4e194b..41780ee 100755 --- a/src/pyelephant.py +++ b/src/pyelephant.py @@ -85,7 +85,11 @@ def show_by_id(session: sa.orm.Session, index: int): # ----------------------------------------------------------------------------- def ls(session: sa.orm.Session, _all: False): - vals = session.query(Task).order_by(Task.created_at) + vals = session.query(Task) + # We must be the final task in a series + vals = vals.filter(~sa.exists().where(Task.id == depends_association.c.second_id)) + vals = vals.order_by(Task.created_at) + if _all is False: vals = vals.filter(Task.active == True) # noqa