Durable image quality: stop trusting feed thumbnails; cycle enriches Latest
Make "no blurry images" sustainable, not a one-off cleanup. RSS feed thumbnails (~44% were ~90px) were stored at ingest and upscaled to mush, so new articles would reintroduce them. Now image_url is filled ONLY by the quality-gated og:image enrichment: * insert_article no longer stores the feed image (was canonicalize_url(item...)). * enrich_recent_images(): the cycle fetches a quality og:image for the newest accepted, imageless articles each run (bounded), keeping Latest photo-rich. * Brief + on-open enrichment unchanged. Net: every stored image is a validated, ≥450px og:image; the rest are clean placeholders. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -78,3 +78,19 @@ def test_image_dimensions_parses_headers():
|
||||
gif = b"GIF89a" + struct.pack("<HH", 90, 90)
|
||||
assert enrich._image_dimensions(gif) == (90, 90)
|
||||
assert enrich._image_dimensions(b"not an image at all") is None
|
||||
|
||||
|
||||
def test_enrich_recent_targets_newest_imageless_accepted(tmp_path):
|
||||
c = _setup(tmp_path)
|
||||
# newest first by published_at; summary not required (unlike the backfill)
|
||||
c.execute("INSERT INTO articles (id,source_id,canonical_url,title,url_hash,image_url,published_at) "
|
||||
"VALUES (1,1,'u1','T1','h1',NULL,'2026-01-01T00:00:00')")
|
||||
c.execute("INSERT INTO articles (id,source_id,canonical_url,title,url_hash,image_url,published_at) "
|
||||
"VALUES (2,1,'u2','T2','h2',NULL,'2026-06-01T00:00:00')") # newest
|
||||
c.execute("INSERT INTO article_scores (article_id,accepted) VALUES (1,1),(2,1)")
|
||||
c.commit()
|
||||
seen = []
|
||||
enrich.enrich_recent_images(c, fetch=lambda url: seen.append(url) or "http://og.jpg", limit=10)
|
||||
# both enriched; newest processed first
|
||||
assert seen[0].endswith("u2")
|
||||
assert c.execute("SELECT image_url FROM articles WHERE id=2").fetchone()[0] == "http://og.jpg"
|
||||
|
||||
Reference in New Issue
Block a user