wohnungen: fall back to scraper data when LLM JSON has nulls
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) <noreply@anthropic.com>
This commit is contained in:
parent
a8f698bf5e
commit
374368e4af
1 changed files with 21 additions and 9 deletions
|
|
@ -154,17 +154,29 @@
|
|||
{% endif %}
|
||||
· <span data-rel-utc="{{ f.discovered_at|iso_utc }}" title="{{ f.discovered_at|de_dt }}">…</span>
|
||||
{% 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 %}<span data-rel-utc="{{ f.discovered_at|iso_utc }}" title="{{ f.discovered_at|de_dt }}">…</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue