Merge pull request 'fix(news): drop future-dated items at ingest, hide them in /api/news' (#52) from wt/t_b8b8e927 into master
Some checks failed
build-and-deploy / build-push-deploy (push) Failing after 6s

This commit is contained in:
sirius 2026-11-14 02:43:23 +00:00
commit 58f71f5b45
5 changed files with 176 additions and 3 deletions

View file

@ -10,7 +10,7 @@ from __future__ import annotations
import asyncio
import os
from datetime import datetime, timezone
from datetime import datetime, timedelta, timezone
import asyncpg
import httpx
@ -157,6 +157,26 @@ def test_api_news_since_filter(clean_news):
assert body[0]["title"] == "after"
@requires_db
def test_api_news_excludes_future_dated_rows(clean_news):
"""Future-dated event listings must not pin the top of the feed."""
now = datetime.now(timezone.utc)
future = now + timedelta(days=5)
recent = now - timedelta(hours=1)
_seed_article("recent", "https://a.example/recent", "a.example", recent.isoformat())
_seed_article("future", "https://a.example/future", "a.example", future.isoformat())
body = _get("/api/news").json()
assert [a["title"] for a in body] == ["recent"]
# limit still caps the (post-filter) result set
_seed_article("recent2", "https://a.example/recent2", "a.example", (now - timedelta(hours=2)).isoformat())
_seed_article("recent3", "https://a.example/recent3", "a.example", (now - timedelta(hours=3)).isoformat())
limited = _get("/api/news?limit=2").json()
assert [a["title"] for a in limited] == ["recent", "recent2"]
@requires_db
def test_api_news_summaries_contract(clean_news):
_seed_summary("master summary markdown…", "2026-08-24T18:05:00+00:00")