Add new on-demand runs
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional
|
||||
from fastapi import APIRouter, HTTPException, Depends
|
||||
from fastapi import APIRouter, BackgroundTasks, HTTPException, Depends
|
||||
from app.models import IncidentCreate, IncidentUpdate
|
||||
from app.internal import firestore as fstore
|
||||
from app.internal.auth import require_admin_token
|
||||
@@ -19,6 +19,14 @@ async def list_incidents(status: Optional[str] = None, type: Optional[str] = Non
|
||||
return await fstore.collection_list("incidents", **filters)
|
||||
|
||||
|
||||
@router.post("/summarize")
|
||||
async def summarize_all_stale(background_tasks: BackgroundTasks):
|
||||
"""Immediately run the summarizer pass on all stale incidents (don't wait for the next interval)."""
|
||||
from app.internal.summarizer import _run_summary_pass
|
||||
background_tasks.add_task(_run_summary_pass)
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.get("/{incident_id}")
|
||||
async def get_incident(incident_id: str):
|
||||
doc = await fstore.doc_get("incidents", incident_id)
|
||||
@@ -67,6 +75,17 @@ async def delete_incident(incident_id: str, _: dict = Depends(require_admin_toke
|
||||
return {"ok": True}
|
||||
|
||||
|
||||
@router.post("/{incident_id}/summarize")
|
||||
async def summarize_incident(incident_id: str, background_tasks: BackgroundTasks):
|
||||
"""Immediately run the summarizer for a specific incident."""
|
||||
from app.internal.summarizer import _summarize_incident
|
||||
inc = await fstore.doc_get("incidents", incident_id)
|
||||
if not inc:
|
||||
raise HTTPException(404, f"Incident '{incident_id}' not found.")
|
||||
background_tasks.add_task(_summarize_incident, inc)
|
||||
return {"ok": True, "incident_id": incident_id}
|
||||
|
||||
|
||||
@router.post("/{incident_id}/calls/{call_id}")
|
||||
async def link_call_to_incident(incident_id: str, call_id: str, _: dict = Depends(require_admin_token)):
|
||||
doc = await fstore.doc_get("incidents", incident_id)
|
||||
|
||||
Reference in New Issue
Block a user