From b1f81132072b647330d320dacefe8eb4f98d38a7 Mon Sep 17 00:00:00 2001 From: UserIsMH Date: Fri, 1 May 2026 23:32:36 +0200 Subject: [PATCH 1/2] Bericht-Export: drei Verbesserungen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Faktencheck immer vollständig PDF-Export hatte im scope=report einen [:20]-Cap, der vollständige Faktencheck wurde nur bei scope=full gerendert. Jetzt ungekürzt überall, sortiert chronologisch absteigend (DB-Sortierung). 2. Status-Labels aus Frontend übernommen FC_STATUS_LABELS hatte nur 4 Werte; in der DB existieren aber 7+ (confirmed/unconfirmed/contradicted/developing/established/ unverified/disputed). Folge: "contradicted" und drei weitere wurden auf englisch ausgegeben. Jetzt 1:1 vom Monitor-UI: contradicted → "Widerlegt" developing → "Unklar" established → "Gesichert" unverified → "Ungeprüft" 3. Adhoc-Export: Neueste Entwicklungen statt Executive Summary Bei Live-Monitoring-Lagen ist die generische Executive Summary weniger aussagekräftig als die kompakten "Neueste Entwicklungen"- Bullets. Endpoint nutzt jetzt: - adhoc + latest_developments vorhanden → latest_developments (Markdown -> HTML konvertiert) - adhoc + leer → cached/generierte Executive Summary (Fallback) - research → unverändert Executive Summary Co-Authored-By: Claude Opus 4.7 (1M context) --- src/report_generator.py | 15 ++++++++++----- src/routers/incidents.py | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/report_generator.py b/src/report_generator.py index 1949a2c..a1e44d0 100644 --- a/src/report_generator.py +++ b/src/report_generator.py @@ -26,10 +26,15 @@ LOGO_PATH = Path(__file__).parent / "static" / "favicon.svg" FC_STATUS_LABELS = { - "confirmed": "Bestätigt", - "unconfirmed": "Unbestätigt", - "disputed": "Umstritten", - "false": "Falsch", + # 1:1 vom Monitor-Frontend (components.js) — konsistent zum UI. + "confirmed": "Bestätigt", + "unconfirmed": "Unbestätigt", + "contradicted": "Widerlegt", + "developing": "Unklar", + "established": "Gesichert", + "disputed": "Umstritten", + "unverified": "Ungeprüft", + "false": "Falsch", # Legacy-Fallback } @@ -709,7 +714,7 @@ async def generate_pdf( ), lagebild_timestamp=(incident.get("updated_at") or "")[:16].replace("T", " "), sources=_prepare_sources(incident)[:30] if scope == "report" else _prepare_sources(incident), - fact_checks=_prepare_fact_checks(fact_checks[:20] if scope == "report" else fact_checks), + fact_checks=_prepare_fact_checks(fact_checks), source_stats=_prepare_source_stats(articles)[:20] if scope == "report" else _prepare_source_stats(articles), timeline=_prepare_timeline(articles) if scope == "full" else [], articles=articles if scope == "full" else [], diff --git a/src/routers/incidents.py b/src/routers/incidents.py index ff64a0a..2173f91 100644 --- a/src/routers/incidents.py +++ b/src/routers/incidents.py @@ -1165,8 +1165,18 @@ async def export_incident( ) snapshots = [dict(r) for r in await cursor.fetchall()] - # Executive Summary (KI-generiert, gecacht) - exec_summary = incident.get("executive_summary") + # Zusammenfassung fuer den Export: + # - Bei Adhoc-Lagen primaer "Neueste Entwicklungen" (latest_developments) als Markdown-Bullets, + # weil Live-Monitoring von Aktualitaet lebt. + # - Fallback (oder bei Research): Executive Summary (KI-generiert, gecacht). + is_adhoc = (incident.get("type") or "adhoc") != "research" + latest_dev = (incident.get("latest_developments") or "").strip() + exec_summary = None + if is_adhoc and latest_dev: + from report_generator import _markdown_to_html as _md_to_html + exec_summary = _md_to_html(latest_dev) + if not exec_summary: + exec_summary = incident.get("executive_summary") if not exec_summary: summary_text = incident.get("summary") or "" exec_summary = await generate_executive_summary(summary_text) -- 2.49.1 From 2b1e8c363238e6dc2470e29d9ea4f61c38a6522f Mon Sep 17 00:00:00 2001 From: UserIsMH Date: Fri, 1 May 2026 23:34:58 +0200 Subject: [PATCH 2/2] requirements.txt: Export-Pakete dokumentiert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Jinja2, weasyprint und python-docx waren auf Live manuell ins venv installiert, fehlten aber in requirements.txt — Folge: auf Staging waren sie nicht installiert, Bericht-Export warf 500 (ModuleNotFoundError). Jetzt im Repo dokumentiert, beim Aufsetzen neuer Umgebungen ist alles vollständig. Co-Authored-By: Claude Opus 4.7 (1M context) --- requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/requirements.txt b/requirements.txt index c84d01e..6880663 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,4 +11,8 @@ python-multipart aiosmtplib geonamescache>=2.0 telethon +# Bericht-Export (PDF via WeasyPrint + DOCX via python-docx) +Jinja2>=3.1 +weasyprint>=68.0 +python-docx>=1.2 pikepdf>=9.0 -- 2.49.1