stage-31 fix: home page 500 — replace bad jinja sum with precomputed count

Template had `{{ buckets|sum(attribute='items')|length }}` which tried
to sum lists starting at 0 → TypeError. Switched to a Python-side
`total_items = sum(len(b.items) for b in buckets)` passed through the
context and rendered directly.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
m17hr1l
2026-05-25 19:05:25 +02:00
parent 76a0b0b636
commit f51e672ad3
2 changed files with 4 additions and 2 deletions

View File

@@ -50,12 +50,14 @@ def index(request: Request) -> HTMLResponse:
got = db.get_case(i.case_id)
if not isinstance(got, Err):
case_index[i.case_id] = case_visuals.case_glyph_svg(got.value)
buckets = news_line.bucket_items(items)
return TEMPLATES.TemplateResponse(
request,
"home.html",
{
"kpis": news_line.kpis(),
"buckets": news_line.bucket_items(items),
"buckets": buckets,
"total_items": sum(len(b.items) for b in buckets),
"feeds": news_line.feed_health(),
"featured": featured,
"featured_hero": case_visuals.case_hero_svg(featured) if featured else "",

View File

@@ -59,7 +59,7 @@
<section class="panel home-news">
<div class="panel-head">
<h2>Recent activity</h2>
<span class="count">{{ buckets|sum(attribute='items')|length }} items</span>
<span class="count">{{ total_items }} items</span>
</div>
<p class="page-intro">Live feed of what psyc has detected and what it has done about it.</p>