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