From 060a33ea5f2a9e26e477787cccd2e5767085ff38 Mon Sep 17 00:00:00 2001 From: Dotty Dotter Date: Thu, 9 Apr 2026 12:11:20 +0200 Subject: [PATCH] PortalaAdapter: client-side Antrag-Filter immer aktiv (#61 Bug 5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BE-Adapter hat document_type=None (eigene ETYPF-Werte werden vom Berliner PARDOK nicht akzeptiert), wodurch der Server alle Doku-Typen zurückliefert. Das 200-Result-Window war damit vollständig von 'Schriftliche Anfrage'-Hits aushungernd, sodass Anträge wie 19/2650 nie ans Frontend kamen — und get_document() für genau diese Drucksachen None lieferte. Patch: client-side 'antrag'-Substring-Filter läuft jetzt unabhängig vom Server-Filter (vorher nur wenn document_type gesetzt war). BB/RP und alle PortalaAdapter-Instanzen profitieren mit. 176 Unit-Tests grün, Live-Verifikation Sub-B im Container nach Deploy. Refs: #61 Bug 5 Co-Authored-By: Claude Opus 4.6 (1M context) --- app/parlamente.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/parlamente.py b/app/parlamente.py index 9cbad29..907fe2f 100644 --- a/app/parlamente.py +++ b/app/parlamente.py @@ -772,15 +772,16 @@ class PortalaAdapter(ParlamentAdapter): results = self._parse_hit_list_html(report_resp.text, query_filter=query) # Server-side ETYPF/DTYPF filter is best-effort across portala # instances — BB/RP let "Kleine Anfrage" und "Beschluss- - # empfehlung" durch (siehe #61 Bug 2/3). Client-side strict - # filter on the parsed typ-string. Whitelist via Substring, - # damit "Antrag gemäß § 79 GO" und ähnliche Subtypen passieren. - if self.document_type: - target = self.document_type.lower() - results = [ - d for d in results - if target in (d.typ or "").lower() - ] + # empfehlung" durch, BE hat sogar `document_type=None` + # (eigene ETYPF-Werte), wodurch "Schriftliche Anfrage" das + # 200-Result-Window aushungern und Anträge wie 19/2650 nie + # zurückkommen. Wir filtern client-side IMMER auf + # "antrag"-Substring im typ — unabhängig davon, ob der + # Server-Filter gesetzt war (siehe #61 Bug 2, 3, 5). + results = [ + d for d in results + if "antrag" in (d.typ or "").lower() + ] return results[:limit] except Exception: