ba801d90f6
- ArticleCard: derive safeHref from article.url and reset image-failure state when the article changes, so in-place replacements re-evaluate correctly (clears the Svelte capture warning; build is warning-free again). - Downweight paywalled stories below readable ones (stable sort) when composing the daily five and in feed results — the brief now leads readable and rarely hands over a locked door. - review_sources gains a 'paywall-heavy' advisory flag (Nature, New Scientist flag at 100%); never auto-deactivates. - New Scientist/Nature kept active but no longer reach the daily five; they remain browsable with the label + Replace. - Tests: brief readability preference + paywall-heavy flag (79 total). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26 lines
981 B
Python
26 lines
981 B
Python
import pytest
|
|
from datetime import datetime, timezone
|
|
|
|
from goodnews.db import connect, init_db
|
|
from goodnews.sources import review_sources
|
|
|
|
|
|
@pytest.fixture
|
|
def conn():
|
|
c = connect(":memory:"); init_db(c)
|
|
c.execute("INSERT INTO sources (id,name,feed_url,trust_score) VALUES (1,'Pay','http://p/f',5)")
|
|
yield c; c.close()
|
|
|
|
|
|
def test_paywall_heavy_flagged(conn):
|
|
now = datetime.now(timezone.utc).isoformat()
|
|
for i in range(20):
|
|
url = f"https://www.newscientist.com/{i}" if i < 15 else f"https://phys.org/{i}"
|
|
conn.execute("INSERT INTO articles (id,source_id,canonical_url,title,published_at,url_hash) "
|
|
"VALUES (?,1,?,?,?,?)", (i, url, f"t{i}", now, f"h{i}"))
|
|
conn.execute("INSERT INTO article_scores (article_id,cortisol_score,ragebait_score,accepted) "
|
|
"VALUES (?,1,0,1)", (i,))
|
|
conn.commit()
|
|
flagged = review_sources(conn)
|
|
assert flagged and "paywall-heavy" in flagged[0]["reason"]
|