use sqlalchemy pattern
This commit is contained in:
19
core/db/job.py
Normal file
19
core/db/job.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""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())
|
||||
Reference in New Issue
Block a user