7455d7e426
130 issues auto-fixed (import ordering, UP045/UP006 type annotations), 33 issues manually fixed (E712/E501/E402/E722 + N818 rename + per-file wechat ignore for N8xx naming conventions). All 33 tests pass.
31 lines
778 B
Python
31 lines
778 B
Python
from fastapi import APIRouter
|
|
|
|
from app.models.schemas import JobResponse
|
|
from app.scheduler.jobs import scheduler
|
|
|
|
router = APIRouter(prefix="/scheduler", tags=["scheduler"])
|
|
|
|
|
|
@router.get("/jobs")
|
|
async def list_jobs():
|
|
jobs = []
|
|
for job in scheduler.get_jobs():
|
|
jobs.append(JobResponse(
|
|
id=job.id,
|
|
name=job.name,
|
|
next_run_time=str(job.next_run_time) if job.next_run_time else None,
|
|
))
|
|
return {"jobs": jobs}
|
|
|
|
|
|
@router.post("/pause/{job_id}")
|
|
async def pause_job(job_id: str):
|
|
scheduler.pause_job(job_id)
|
|
return {"status": "paused", "job_id": job_id}
|
|
|
|
|
|
@router.post("/resume/{job_id}")
|
|
async def resume_job(job_id: str):
|
|
scheduler.resume_job(job_id)
|
|
return {"status": "resumed", "job_id": job_id}
|