From f51e672ad39feb9aa43c9371aa568776580761c3 Mon Sep 17 00:00:00 2001 From: m17hr1l Date: Mon, 25 May 2026 19:05:25 +0200 Subject: [PATCH] =?UTF-8?q?stage-31=20fix:=20home=20page=20500=20=E2=80=94?= =?UTF-8?q?=20replace=20bad=20jinja=20sum=20with=20precomputed=20count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/psyc/cockpit/app.py | 4 +++- src/psyc/cockpit/templates/home.html | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/psyc/cockpit/app.py b/src/psyc/cockpit/app.py index 57e0ce4..eef212d 100644 --- a/src/psyc/cockpit/app.py +++ b/src/psyc/cockpit/app.py @@ -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 "", diff --git a/src/psyc/cockpit/templates/home.html b/src/psyc/cockpit/templates/home.html index 3835d41..381c1f4 100644 --- a/src/psyc/cockpit/templates/home.html +++ b/src/psyc/cockpit/templates/home.html @@ -59,7 +59,7 @@

Recent activity

- {{ buckets|sum(attribute='items')|length }} items + {{ total_items }} items

Live feed of what psyc has detected and what it has done about it.