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:
@@ -50,12 +50,14 @@ def index(request: Request) -> HTMLResponse:
|
|||||||
got = db.get_case(i.case_id)
|
got = db.get_case(i.case_id)
|
||||||
if not isinstance(got, Err):
|
if not isinstance(got, Err):
|
||||||
case_index[i.case_id] = case_visuals.case_glyph_svg(got.value)
|
case_index[i.case_id] = case_visuals.case_glyph_svg(got.value)
|
||||||
|
buckets = news_line.bucket_items(items)
|
||||||
return TEMPLATES.TemplateResponse(
|
return TEMPLATES.TemplateResponse(
|
||||||
request,
|
request,
|
||||||
"home.html",
|
"home.html",
|
||||||
{
|
{
|
||||||
"kpis": news_line.kpis(),
|
"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(),
|
"feeds": news_line.feed_health(),
|
||||||
"featured": featured,
|
"featured": featured,
|
||||||
"featured_hero": case_visuals.case_hero_svg(featured) if featured else "",
|
"featured_hero": case_visuals.case_hero_svg(featured) if featured else "",
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<section class="panel home-news">
|
<section class="panel home-news">
|
||||||
<div class="panel-head">
|
<div class="panel-head">
|
||||||
<h2>Recent activity</h2>
|
<h2>Recent activity</h2>
|
||||||
<span class="count">{{ buckets|sum(attribute='items')|length }} items</span>
|
<span class="count">{{ total_items }} items</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="page-intro">Live feed of what psyc has detected and what it has done about it.</p>
|
<p class="page-intro">Live feed of what psyc has detected and what it has done about it.</p>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user