Basisimplementierung für Mailversandt.
This commit is contained in:
parent
8505e9217a
commit
531b9cb10e
14 changed files with 520 additions and 41 deletions
26
app/schema_utils.py
Normal file
26
app/schema_utils.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
from typing import List
|
||||
from app.schemas import JobInfo, TaskInfo
|
||||
from app.models import Job, Task
|
||||
|
||||
def job_to_schema(job: Job) -> JobInfo:
|
||||
tasks: List[TaskInfo] = [
|
||||
TaskInfo(
|
||||
id=t.id,
|
||||
name=t.name,
|
||||
status=t.status.value if hasattr(t.status, "value") else str(t.status),
|
||||
retries=t.retries,
|
||||
max_retries=t.max_retries,
|
||||
result=t.result,
|
||||
error=t.error,
|
||||
)
|
||||
for t in job.tasks
|
||||
]
|
||||
return JobInfo(
|
||||
id=job.id,
|
||||
job_type=job.job_type,
|
||||
status=job.status.value if hasattr(job.status, "value") else str(job.status),
|
||||
domain=job.domain,
|
||||
payload=job.payload,
|
||||
tasks=tasks,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue