From 26014297f460bc640bef0284429c9648f1192f41 Mon Sep 17 00:00:00 2001 From: jay Date: Tue, 9 Jun 2026 12:09:17 -0400 Subject: [PATCH] Attention: long rate-limit item scans active sources only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per Codex: a paused/retired source with a future retry_after_at shouldn't nag 'rate-limited for 12h+' — it's intentionally out of polling. Scope long_rest to active (matching the other operational items). Test: paused/retired rate-limited sources stay quiet. Co-Authored-By: Claude Opus 4.8 (1M context) --- goodnews/queries.py | 2 +- tests/test_dashboard.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/goodnews/queries.py b/goodnews/queries.py index c66a44b..9759ea9 100644 --- a/goodnews/queries.py +++ b/goodnews/queries.py @@ -395,7 +395,7 @@ def _attention(content: dict, sources: list[dict], feedback_unread: int, now: da # Long rate-limit rest (info). rest_cutoff = (now + timedelta(hours=_LONG_REST_HOURS)).strftime("%Y-%m-%d %H:%M:%S") - long_rest = [s for s in sources if s.get("retry_after_at") and s["retry_after_at"] > rest_cutoff] + long_rest = [s for s in active if s.get("retry_after_at") and s["retry_after_at"] > rest_cutoff] if long_rest: items.append({"level": "info", "text": f"{len(long_rest)} source{n(len(long_rest))} rate-limited for {_LONG_REST_HOURS}h+"}) diff --git a/tests/test_dashboard.py b/tests/test_dashboard.py index 7d0521e..06624db 100644 --- a/tests/test_dashboard.py +++ b/tests/test_dashboard.py @@ -114,3 +114,16 @@ def test_attention_quiet_below_thresholds(): {"status": "paused", "content_visible": 1, "last_success_at": "2020-01-01 00:00:00"}, # paused → ignored ] assert queries._attention(content, sources, 0, now=now) == [] + + +def test_attention_ignores_rate_limit_on_paused_or_retired(): + from datetime import UTC, datetime + from goodnews import queries + now = datetime(2026, 6, 9, 12, 0, 0, tzinfo=UTC) + content = {"served": 100, "with_image": 95, "latest_brief_size": 7} + sources = [ + {"status": "paused", "retry_after_at": "2026-06-12 00:00:00"}, # intentionally not polling + {"status": "retired", "retry_after_at": "2026-06-12 00:00:00"}, + ] + # neither should nag about a rate-limit rest + assert queries._attention(content, sources, 0, now=now) == []