feat(P4.3): wire task depend_on check into pending→open transition via reusable helper
This commit is contained in:
@@ -111,3 +111,38 @@ def check_milestone_deps(
|
||||
result.blockers.append(f"Dependent tasks not {required_status}: {incomplete_tasks}")
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def check_task_deps(
|
||||
db: Session,
|
||||
depend_on: str | None,
|
||||
*,
|
||||
required_status: str = "completed",
|
||||
) -> DepCheckResult:
|
||||
"""Check whether a task's depend_on tasks are all satisfied.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
db:
|
||||
Active DB session.
|
||||
depend_on:
|
||||
JSON-encoded list of task IDs (from the task's ``depend_on`` field).
|
||||
required_status:
|
||||
The status dependees must have reached (default ``"completed"``).
|
||||
|
||||
Returns
|
||||
-------
|
||||
DepCheckResult with ``ok=True`` if all deps satisfied, else ``ok=False``
|
||||
with human-readable ``blockers``.
|
||||
"""
|
||||
result = DepCheckResult()
|
||||
task_ids = _parse_json_ids(depend_on)
|
||||
if task_ids:
|
||||
dep_tasks: Sequence[Task] = (
|
||||
db.query(Task).filter(Task.id.in_(task_ids)).all()
|
||||
)
|
||||
incomplete = [t.id for t in dep_tasks if _task_status(t) != required_status]
|
||||
if incomplete:
|
||||
result.ok = False
|
||||
result.blockers.append(f"Dependent tasks not {required_status}: {incomplete}")
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user