List only tasks that are leaves on the task tree

This commit is contained in:
Danny Robson 2020-06-09 13:18:07 +10:00
parent 8fa3551ed6
commit b8c3c28bcd

View File

@ -85,7 +85,11 @@ def show_by_id(session: sa.orm.Session, index: int):
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
def ls(session: sa.orm.Session, _all: False): 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: if _all is False:
vals = vals.filter(Task.active == True) # noqa vals = vals.filter(Task.active == True) # noqa