Add hourly RecentlyOnScope batch endpoint

This commit is contained in:
2026-05-22 16:14:08 +02:00
parent c95d29023d
commit cea59d7f13
5 changed files with 297 additions and 0 deletions

View File

@@ -8,17 +8,38 @@ from api.database import get_session
from api.schemas.recently_on_scope import (
RecentlyOnScopeGenerate,
RecentlyOnScopeGeneratedReport,
RecentlyOnScopeHourlyGenerate,
RecentlyOnScopeHourlyRun,
RecentlyOnScopeReportMetadata,
)
from api.services.markitect_templates import MarkitectRenderError, MarkitectUnavailable
from api.services.recently_on_scope import (
generate_report,
generate_hourly_reports,
list_reports,
read_report,
resolve_window,
)
router = APIRouter(prefix="/domains/{slug}/recently-on-scope", tags=["recently-on-scope"])
hourly_router = APIRouter(prefix="/recently-on-scope", tags=["recently-on-scope"])
@hourly_router.post("/hourly", response_model=RecentlyOnScopeHourlyRun, status_code=status.HTTP_201_CREATED)
async def generate_hourly_recently_on_scope(
body: RecentlyOnScopeHourlyGenerate,
session: AsyncSession = Depends(get_session),
) -> RecentlyOnScopeHourlyRun:
try:
window = resolve_window(body.range, body.since, body.until)
return await generate_hourly_reports(
session,
window,
active_only=body.active_only,
include_attention=body.include_attention,
)
except ValueError as exc:
raise HTTPException(status_code=422, detail=str(exc)) from exc
@router.post("/", response_model=RecentlyOnScopeGeneratedReport, status_code=status.HTTP_201_CREATED)