Sources table: Media column (image coverage % + paywall marker)
Per Codex — make the table more decision-ready from data we already have. Paywall is a domain-level hint, so it's a per-source flag (not a meaningful rate): show image-coverage % plus a 🔒 marker for subscription domains in one compact "Media" column (tooltip spells it out). source_health gains a `paywalled` flag (is_paywalled on homepage/feed); also added to sources.csv. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -127,3 +127,21 @@ def test_attention_ignores_rate_limit_on_paused_or_retired():
|
||||
]
|
||||
# neither should nag about a rate-limit rest
|
||||
assert queries._attention(content, sources, 0, now=now) == []
|
||||
|
||||
|
||||
def test_source_health_paywall_and_image_coverage(tmp_path):
|
||||
import sqlite3
|
||||
from goodnews.db import connect, init_db
|
||||
from goodnews import queries
|
||||
c = connect(str(tmp_path / "t.db")); init_db(c)
|
||||
# a paywalled-domain source and a free one, each with a served article
|
||||
c.execute("INSERT INTO sources (id,name,feed_url,homepage_url,active) VALUES (1,'NS','http://x/f','https://www.nature.com',1)")
|
||||
c.execute("INSERT INTO sources (id,name,feed_url,homepage_url,active) VALUES (2,'Free','http://y/f','https://goodsite.org',1)")
|
||||
for aid, sid, img in [(1, 1, 'http://i/1.jpg'), (2, 2, None)]:
|
||||
c.execute("INSERT INTO articles (id,source_id,canonical_url,title,url_hash,image_url) VALUES (?,?,?,?,?,?)",
|
||||
(aid, sid, f'http://u/{aid}', f't{aid}', f'h{aid}', img))
|
||||
c.execute("INSERT INTO article_scores (article_id,accepted) VALUES (?,1)", (aid,))
|
||||
c.commit()
|
||||
sh = {s["id"]: s for s in queries.source_health(c)}
|
||||
assert sh[1]["paywalled"] is True and sh[2]["paywalled"] is False
|
||||
assert sh[1]["image_coverage"] == 100 and sh[2]["image_coverage"] == 0
|
||||
|
||||
Reference in New Issue
Block a user