fix(antrag-detail, merkliste): Score in Merkliste + Metadaten-Whitespace (#177)
Zwei kleine UI-Bugs:
1) Score in Merkliste fehlte. Ursache: /api/assessment liefert ``gwoeScore``
(camelCase), das Merkliste-Template las ``a.gwoe_score`` (snake_case).
Fix: beide Schreibweisen akzeptieren.
2) Metadaten-Zeile im Antrag-Detail rendert mit Whitespace-Müll, weil die
Jinja-If-Blöcke ohne Whitespace-Steuerung Newlines durchlassen, die
der Browser zu Spaces collapst:
- "13.04.2026 , qwen-plus" (Komma mit Leerzeichen davor) statt
"13.04.2026, qwen-plus".
- "NRW-WP18. Wahlperiode" statt "18. Wahlperiode": ``antrag.wahlperiode``
ist der Filter-Key wie "NRW-WP18", nicht die reine Zahl.
Fix: Whitespace-Steuerung ``{%- ... -%}`` an allen relevanten If-Tags
in der Metadaten-Zeile + Byline. Plus neues Feld
``antrag.wahlperiode_zahl`` (nur die Zahl) im _row_to_detail-Mapping,
das bevorzugt vor ``antrag.wahlperiode`` zur Anzeige genutzt wird.
Vorher: NRW · Drs. 18/18246 · Antrag · NRW-WP18. Wahlperiode · eingebracht 18.03.2026
Eingebracht von SPD — Analyse 13.04.2026 , qwen-plus · 5 Zitate verifiziert
Nachher: NRW · Drs. 18/18246 · Antrag · 18. Wahlperiode · eingebracht 18.03.2026
Eingebracht von SPD — Analyse 13.04.2026, qwen-plus · 5 Zitate verifiziert
This commit is contained in:
parent
35fed45339
commit
1a3aa9bbcb
24
app/main.py
24
app/main.py
@ -675,7 +675,11 @@ def _row_to_detail(row):
|
||||
"link": row.get("link") or "",
|
||||
"konfidenz": row.get("konfidenz") or "",
|
||||
"fehlende_programme": row.get("fehlende_programme") or [],
|
||||
# ``wahlperiode``: Filter-Key wie "NRW-WP18" — wird in den Auswertungs-
|
||||
# Filtern als Stable-Key benutzt. ``wahlperiode_zahl``: nur die Zahl
|
||||
# (z.B. 18) für die Anzeige im Antrag-Detail.
|
||||
"wahlperiode": _wahlperiode_silent(row.get("datum", ""), row.get("bundesland", "")),
|
||||
"wahlperiode_zahl": _wahlperiode_zahl_silent(row.get("datum", ""), row.get("bundesland", "")),
|
||||
# Roher ISO-Zeitstempel für OG-Cache-Key (#141)
|
||||
"updated_at_raw": row.get("updated_at", ""),
|
||||
}
|
||||
@ -691,6 +695,26 @@ def _wahlperiode_silent(datum: str, bundesland: str) -> str:
|
||||
return ""
|
||||
|
||||
|
||||
def _wahlperiode_zahl_silent(datum: str, bundesland: str) -> Optional[int]:
|
||||
"""Wahlperiode als Zahl (z.B. 18) für die Anzeige. ``None`` wenn unklar.
|
||||
|
||||
``wahlperiode_for`` liefert ``"<BL>-WP<N>"`` als Filter-Key — extrahieren
|
||||
wir hier die N-Komponente, damit das Template "18. Wahlperiode" zeigen
|
||||
kann statt "NRW-WP18. Wahlperiode".
|
||||
"""
|
||||
raw = _wahlperiode_silent(datum, bundesland)
|
||||
if not raw:
|
||||
return None
|
||||
import re
|
||||
m = re.search(r"WP(\d+)", raw)
|
||||
if m:
|
||||
try:
|
||||
return int(m.group(1))
|
||||
except ValueError:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
@app.post("/analyze")
|
||||
@limiter.limit("10/minute")
|
||||
async def start_analysis(
|
||||
|
||||
@ -226,7 +226,10 @@ function showToast(msg) {
|
||||
}
|
||||
|
||||
function renderRow(a) {
|
||||
var score = (typeof a.gwoe_score === 'number') ? a.gwoe_score.toFixed(1) : '—';
|
||||
// /api/assessment liefert gwoeScore (camelCase), nicht gwoe_score.
|
||||
var score = (typeof a.gwoeScore === 'number') ? a.gwoeScore.toFixed(1)
|
||||
: (typeof a.gwoe_score === 'number') ? a.gwoe_score.toFixed(1)
|
||||
: '—';
|
||||
var bl = a.bundesland || '';
|
||||
var fraktion = (a.fraktionen || []).join(', ');
|
||||
var title = a.title || a.titel || a.drucksache;
|
||||
|
||||
@ -49,20 +49,23 @@
|
||||
|
||||
{# 1 ── Metadaten + Titel ─────────────────────────────────────────── #}
|
||||
<section class="v3-section v3-meta">
|
||||
{# Whitespace-Steuerung: alle Jinja-Tags auf einer Zeile, sonst entstehen
|
||||
Newlines die der Browser als Spaces rendert ("13.04.2026 , qwen-plus"
|
||||
statt "13.04.2026, qwen-plus"). #}
|
||||
<div class="v3-antrag-id">
|
||||
{{ antrag.bundesland | default("") }}
|
||||
{% if antrag.drucksache %} · Drs. {{ antrag.drucksache }}{% endif %}
|
||||
{% if antrag.typ %} · {{ antrag.typ }}{% endif %}
|
||||
{% if antrag.wahlperiode %} · {{ antrag.wahlperiode }}. Wahlperiode{% endif %}
|
||||
{% if antrag.datum %} · eingebracht {{ antrag.datum }}{% endif %}
|
||||
{{- antrag.bundesland | default("") -}}
|
||||
{%- if antrag.drucksache %} · Drs. {{ antrag.drucksache }}{% endif -%}
|
||||
{%- if antrag.typ %} · {{ antrag.typ }}{% endif -%}
|
||||
{%- if antrag.wahlperiode_zahl %} · {{ antrag.wahlperiode_zahl }}. Wahlperiode{% elif antrag.wahlperiode %} · {{ antrag.wahlperiode }}. Wahlperiode{% endif -%}
|
||||
{%- if antrag.datum %} · eingebracht {{ antrag.datum }}{% endif -%}
|
||||
</div>
|
||||
<h1 class="v3-title">{{ antrag.title | default("Antrag") }}</h1>
|
||||
{% if antrag.parteien or antrag.analysiert %}
|
||||
<div class="v3-byline">
|
||||
{% if antrag.parteien %}Eingebracht von {{ antrag.parteien | join(", ") }}{% endif %}
|
||||
{% if antrag.analysiert %} — Analyse {{ antrag.analysiert }}{% endif %}
|
||||
{% if antrag.modell %}, {{ antrag.modell }}{% endif %}
|
||||
{% if antrag.zitate_count %} · {{ antrag.zitate_count }} Zitat{{ "e" if antrag.zitate_count != 1 else "" }} verifiziert{% endif %}
|
||||
{%- if antrag.parteien %}Eingebracht von {{ antrag.parteien | join(", ") }}{% endif -%}
|
||||
{%- if antrag.analysiert %} — Analyse {{ antrag.analysiert }}{% endif -%}
|
||||
{%- if antrag.modell %}, {{ antrag.modell }}{% endif -%}
|
||||
{%- if antrag.zitate_count %} · {{ antrag.zitate_count }} Zitat{{ "e" if antrag.zitate_count != 1 else "" }} verifiziert{% endif -%}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if antrag.themen %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user