fix(news): drop future-dated items at ingest, hide them in /api/news #52
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_b8b8e927"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up on the frozen-looking news feed:
wiseye.orgpublic-affairs event listings carry apubDate3-6 days ahead of now, soORDER BY articles.timestamp DESC NULLS LASTparked 12 of them at the top of/api/newsfor a week.Two independent guards (per spec, both needed):
PostgresPipelinedrops items whose parsed publish date is more than 2 hours in the future, increments the Scrapy stats keyfuture_dated_droppedand logs one INFO line per run inclose_spider()(no per-item spam). Unparseable/absent dates keep the previous behaviour — they are still kept.GET /api/newsadds aWHERE (timestamp IS NULL OR timestamp <= now())clause to the existing query (no post-filter). Ordering,limit/offset/domain/sincesemantics and NULL-timestamp visibility are unchanged./api/newsis the only endpoint that listsarticlesordered bytimestamp.No migration, no new column, no existing rows deleted,
urls.txtuntouched.Docs:
docs/news.mddata-flow section now states the guarantee.Verification
pytest -q(DB-backed, scratch PG on :55432): before 189 passed onmaster, after 193 passed, 1 warning (4 new tests: 3 pipeline incl.now+5ddropped /now-1dkept / unparseable kept; 1 API test seeding a future + recent row, asserting only the recent one comes back andlimitstill caps). Note: the new pipeline tests need the scraper deps (scrapy,psycopg2-binary) importable.now() + 5 daysandnow() - 1 hourrows →/api/newsreturned only the recent row (limit=1still capped); atimestamp IS NULLrow stayed visible (sorted last); future row deleted afterwards.Premise holds: the rows are feed
pubDatevalues, not crawl time (article_timestamp()only falls back tonow()when the date is unparseable, and those are never in the future). The 12 existing DB rows become visible only when their date arrives, which is correct for event listings.Merge policy: leaving this open for the operator to merge + rebuild the amd64 image + pin in
sirius/homek8sapps/base/osint/.