20 lines
481 B
Python
20 lines
481 B
Python
"""Job queries."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
from uuid import UUID
|
|
|
|
from sqlmodel import Session, select
|
|
|
|
from .tables import Job
|
|
|
|
|
|
def list_jobs(session: Session, parent_id: Optional[UUID] = None, status: Optional[str] = None) -> list[Job]:
|
|
stmt = select(Job)
|
|
if parent_id:
|
|
stmt = stmt.where(Job.parent_id == parent_id)
|
|
if status:
|
|
stmt = stmt.where(Job.status == status)
|
|
return list(session.exec(stmt).all())
|