From 374368e4af3724d18896afdb76baf77f9f5374b5 Mon Sep 17 00:00:00 2001 From: EiSiMo Date: Tue, 21 Apr 2026 15:21:11 +0200 Subject: [PATCH] wohnungen: fall back to scraper data when LLM JSON has nulls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many listings die or 404 within hours of being published, and several landlord pages render their stats via JS that our Playwright fetch doesn't reliably catch. In those cases the LLM correctly returns nulls — but we'd then show "2 Z · vor 30 min" and lose the m²/€/WBS info that the inberlinwohnen.de scraper had captured authoritatively. The list now coalesces: e.rooms / e.size_sqm / e.rent_total or rent_cold / e.wbs_required take precedence; when null we fall back to f.rooms, f.size, f.total_rent, f.wbs respectively. Boolean wbs_required uses `is sameas` so an explicit `false` (no-WBS) from the LLM is preserved instead of being treated as missing. Co-Authored-By: Claude Opus 4.7 (1M context) --- web/templates/_wohnungen_body.html | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/web/templates/_wohnungen_body.html b/web/templates/_wohnungen_body.html index 58eb219..fda8748 100644 --- a/web/templates/_wohnungen_body.html +++ b/web/templates/_wohnungen_body.html @@ -154,17 +154,29 @@ {% endif %} · {% else %} + {# LLM first, scraper as fallback. The scraper data + from inberlinwohnen.de is reliable; we only + replace it when the LLM has a concrete value. #} {% set e = item.enrichment or {} %} - {% set parts = [] %} - {% if e.rooms %}{% set _ = parts.append('%g Z'|format(e.rooms)) %}{% endif %} - {% if e.size_sqm %}{% set _ = parts.append('%.0f m²'|format(e.size_sqm)) %}{% endif %} - {% set rent = e.rent_total or e.rent_cold %} - {% if rent %}{% set _ = parts.append('%.0f €'|format(rent)) %}{% endif %} - {% if e.wbs_required is true %} - {% set _ = parts.append('WBS: ' ~ (e.wbs_type or 'erforderlich')) %} - {% elif e.wbs_required is false %} - {% set _ = parts.append('ohne WBS') %} + {% set rooms = e.rooms if e.rooms is not none else f.rooms %} + {% set size = e.size_sqm if e.size_sqm is not none else f.size %} + {% set rent = e.rent_total or e.rent_cold or f.total_rent %} + {% if e.wbs_required is sameas true %} + {% set wbs_label = 'WBS: ' ~ (e.wbs_type or 'erforderlich') %} + {% elif e.wbs_required is sameas false %} + {% set wbs_label = 'ohne WBS' %} + {% elif f.wbs == 'erforderlich' %} + {% set wbs_label = 'WBS: erforderlich' %} + {% elif f.wbs == 'nicht erforderlich' %} + {% set wbs_label = 'ohne WBS' %} + {% else %} + {% set wbs_label = '' %} {% endif %} + {% set parts = [] %} + {% if rooms %}{% set _ = parts.append('%g Z'|format(rooms)) %}{% endif %} + {% if size %}{% set _ = parts.append('%.0f m²'|format(size)) %}{% endif %} + {% if rent %}{% set _ = parts.append('%.0f €'|format(rent)) %}{% endif %} + {% if wbs_label %}{% set _ = parts.append(wbs_label) %}{% endif %} {{ parts|join(' · ') }}{% if parts %} · {% endif %} {% endif %}