fix(news): drop future-dated items at ingest, hide them in /api/news #52

Merged
sirius merged 1 commit from wt/t_b8b8e927 into master 2026-11-14 02:43:24 +00:00
Owner

Follow-up on the frozen-looking news feed: wiseye.org public-affairs event listings carry a pubDate 3-6 days ahead of now, so ORDER BY articles.timestamp DESC NULLS LAST parked 12 of them at the top of /api/news for a week.

Two independent guards (per spec, both needed):

  1. Ingest — PostgresPipeline drops items whose parsed publish date is more than 2 hours in the future, increments the Scrapy stats key future_dated_dropped and logs one INFO line per run in close_spider() (no per-item spam). Unparseable/absent dates keep the previous behaviour — they are still kept.
  2. API — GET /api/news adds a WHERE (timestamp IS NULL OR timestamp <= now()) clause to the existing query (no post-filter). Ordering, limit/offset/domain/since semantics and NULL-timestamp visibility are unchanged. /api/news is the only endpoint that lists articles ordered by timestamp.

No migration, no new column, no existing rows deleted, urls.txt untouched.

Docs: docs/news.md data-flow section now states the guarantee.

Verification

  • pytest -q (DB-backed, scratch PG on :55432): before 189 passed on master, after 193 passed, 1 warning (4 new tests: 3 pipeline incl. now+5d dropped / now-1d kept / unparseable kept; 1 API test seeding a future + recent row, asserting only the recent one comes back and limit still caps). Note: the new pipeline tests need the scraper deps (scrapy, psycopg2-binary) importable.
  • Manual against the scratch DB via uvicorn on the branch: inserted now() + 5 days and now() - 1 hour rows → /api/news returned only the recent row (limit=1 still capped); a timestamp IS NULL row stayed visible (sorted last); future row deleted afterwards.

Premise holds: the rows are feed pubDate values, not crawl time (article_timestamp() only falls back to now() 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/homek8s apps/base/osint/.

Follow-up on the frozen-looking news feed: `wiseye.org` public-affairs event listings carry a `pubDate` 3-6 days ahead of now, so `ORDER BY articles.timestamp DESC NULLS LAST` parked 12 of them at the top of `/api/news` for a week. Two independent guards (per spec, both needed): 1. **Ingest** — `PostgresPipeline` drops items whose parsed publish date is more than 2 hours in the future, increments the Scrapy stats key `future_dated_dropped` and logs one INFO line per run in `close_spider()` (no per-item spam). Unparseable/absent dates keep the previous behaviour — they are still kept. 2. **API** — `GET /api/news` adds a `WHERE (timestamp IS NULL OR timestamp <= now())` clause to the existing query (no post-filter). Ordering, `limit`/`offset`/`domain`/`since` semantics and NULL-timestamp visibility are unchanged. `/api/news` is the only endpoint that lists `articles` ordered by `timestamp`. No migration, no new column, no existing rows deleted, `urls.txt` untouched. Docs: `docs/news.md` data-flow section now states the guarantee. ## Verification - `pytest -q` (DB-backed, scratch PG on :55432): **before 189 passed** on `master`, **after 193 passed, 1 warning** (4 new tests: 3 pipeline incl. `now+5d` dropped / `now-1d` kept / unparseable kept; 1 API test seeding a future + recent row, asserting only the recent one comes back and `limit` still caps). Note: the new pipeline tests need the scraper deps (`scrapy`, `psycopg2-binary`) importable. - Manual against the scratch DB via uvicorn on the branch: inserted `now() + 5 days` and `now() - 1 hour` rows → `/api/news` returned only the recent row (`limit=1` still capped); a `timestamp IS NULL` row stayed visible (sorted last); future row deleted afterwards. Premise holds: the rows are feed `pubDate` values, not crawl time (`article_timestamp()` only falls back to `now()` 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/homek8s` `apps/base/osint/`.
wiseye.org public-affairs event listings carry pubDate 3-6 days ahead; with
ORDER BY timestamp DESC they pinned the top of the feed for a week and made
the news list look frozen.

- PostgresPipeline drops items whose parsed publish date is >2h in the
  future, counts future_dated_dropped (stats + one INFO line per run).
  Unparseable dates keep the old behaviour (kept, timestamped now()).
- GET /api/news filters timestamp > now() in the query while still returning
  timestamp IS NULL rows; limit/offset/domain/since unchanged.
- docs/news.md documents the guard.
- tests: pipeline drop/keep unit tests, API future-row exclusion + limit.
sirius merged commit 58f71f5b45 into master 2026-11-14 02:43:24 +00:00
sirius deleted branch wt/t_b8b8e927 2026-11-14 02:43:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/osint-dashboard!52
No description provided.