fix simulation reporting and research resilience
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
from fastapi import APIRouter, Request, HTTPException
|
||||
from fastapi import APIRouter, Request, HTTPException
|
||||
from app.services.narrator import REPORT_SCHEMA_VERSION
|
||||
|
||||
router = APIRouter(prefix="/api")
|
||||
|
||||
@@ -18,8 +19,12 @@ async def get_gallery_item(sim_id: str, request: Request):
|
||||
raise HTTPException(404, "Simulation not found in gallery")
|
||||
await store.increment_view_count(sim_id)
|
||||
cached = await store.get_report(sim_id)
|
||||
if cached and cached.get("status") == "ready":
|
||||
return cached["report"]
|
||||
if (
|
||||
cached
|
||||
and cached.get("status") == "ready"
|
||||
and cached.get("report", {}).get("report_schema_version") == REPORT_SCHEMA_VERSION
|
||||
):
|
||||
return cached["report"]
|
||||
narrator = request.app.state.narrator
|
||||
report = await narrator.generate_report(sim_id, store)
|
||||
if "error" not in report:
|
||||
|
||||
Reference in New Issue
Block a user