Perf: Executive Summary nach Refresh im Hintergrund vorberechnen
Statt beim PDF-Export 30+ Sekunden auf die KI-Zusammenfassung zu warten, wird sie jetzt automatisch nach jedem Refresh generiert. Beim Export ist sie dann sofort verfuegbar (gecacht in DB). Summary-Aenderungen invalidieren den Cache automatisch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dieser Commit ist enthalten in:
@@ -1174,7 +1174,7 @@ class AgentOrchestrator:
|
|||||||
sources_json = json.dumps(sources, ensure_ascii=False) if sources else previous_sources_json
|
sources_json = json.dumps(sources, ensure_ascii=False) if sources else previous_sources_json
|
||||||
|
|
||||||
await db.execute(
|
await db.execute(
|
||||||
"UPDATE incidents SET summary = ?, sources_json = ?, updated_at = ? WHERE id = ?",
|
"UPDATE incidents SET summary = ?, sources_json = ?, executive_summary = NULL, updated_at = ? WHERE id = ?",
|
||||||
(new_summary, sources_json, now, incident_id),
|
(new_summary, sources_json, now, incident_id),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1470,6 +1470,33 @@ class AgentOrchestrator:
|
|||||||
|
|
||||||
logger.info(f"Refresh für Lage {incident_id} abgeschlossen: {new_count} neue Artikel")
|
logger.info(f"Refresh für Lage {incident_id} abgeschlossen: {new_count} neue Artikel")
|
||||||
|
|
||||||
|
# Executive Summary im Hintergrund vorab generieren (fuer schnelleren Export)
|
||||||
|
if new_count > 0:
|
||||||
|
async def _pregenerate_exec_summary():
|
||||||
|
try:
|
||||||
|
from report_generator import generate_executive_summary
|
||||||
|
from database import get_db
|
||||||
|
_db = await get_db()
|
||||||
|
try:
|
||||||
|
cursor = await _db.execute(
|
||||||
|
"SELECT summary, executive_summary FROM incidents WHERE id = ?",
|
||||||
|
(incident_id,),
|
||||||
|
)
|
||||||
|
_row = await cursor.fetchone()
|
||||||
|
if _row and _row["summary"] and not _row["executive_summary"]:
|
||||||
|
es = await generate_executive_summary(_row["summary"])
|
||||||
|
await _db.execute(
|
||||||
|
"UPDATE incidents SET executive_summary = ? WHERE id = ?",
|
||||||
|
(es, incident_id),
|
||||||
|
)
|
||||||
|
await _db.commit()
|
||||||
|
logger.info(f"Executive Summary fuer Lage {incident_id} vorberechnet")
|
||||||
|
finally:
|
||||||
|
await _db.close()
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"Executive Summary Vorberechnung fehlgeschlagen: {e}")
|
||||||
|
asyncio.create_task(_pregenerate_exec_summary())
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
await db.close()
|
await db.close()
|
||||||
|
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren