Add news pipeline: hourly scraper + Gemini summarizer in compose
Some checks failed
build-and-deploy / build (push) Failing after 4s

Vendor the newsPipeline scraper + summarizer into the repo and wire them into
docker-compose against the EXISTING osint-db (no second Postgres), replacing
the upstream k8s CronJobs with in-compose wall-clock loops (:00 scrape, :05
summarize).

- news/scraper: vendored Scrapy project (257 RSS feeds) + hourly loop
  scheduler (run_news_scraper.py)
- news/summerizer: vendored Gemini map-reduce summarizer, cleaned:
  * fix broken google-genai response handling (_extract_text, defensive)
  * fix malformed INSERT/GRANT query in save_summary_to_db
  * OSINT-neutral default MAP_PROMPT; futures/markets language gated behind
    INCLUDE_FUTURES=0 (yfinance lazy-imported)
  * env-configurable model, batch size, lookback window
  + hourly loop scheduler (run_news_summarizer.py, :05)
- alembic 003_news: idempotent articles + article_summaries tables
- API: GET /api/news and GET /api/news/summaries (+ models, schemas)
- tests/test_api_news.py: 5 DB-backed contract tests (all pass vs real PG)
- docs/news.md + .env.example updates

Both services run under the `ingest` compose profile (matching the
ingester/camera-scraper pattern) and build arm64 on the Pi via the existing
Forgejo CI workflow. telebot left out of scope (reserved env only).
This commit is contained in:
Sirius DevOps 2026-08-24 17:28:46 -04:00
commit 91f436390b
27 changed files with 1772 additions and 2 deletions

View file

@ -182,3 +182,33 @@ fires = Table(
# Bounding-box index for `bbox=` filtering (lon first for max/min-lon scans).
Index("ix_fires_bbox", fires.c.longitude, fires.c.latitude)
# ── News pipeline (scraper + summarizer) ──────────────────────────────────
# Written by the vendored news-scraper (Scrapy) / news-summarizer (Gemini)
# services; schema must match the idempotent alembic migration 003_news.
articles = Table(
"articles",
metadata,
Column("id", Integer, primary_key=True, autoincrement=True),
Column("title", Text),
Column("url", Text, unique=True), # dedup key
Column("content", Text), # full extracted article text
Column("domain", Text), # source domain
Column("timestamp", DateTime(timezone=True)), # capture time
)
Index("ix_articles_timestamp", articles.c.timestamp)
article_summaries = Table(
"article_summaries",
metadata,
Column("id", Integer, primary_key=True, autoincrement=True),
Column("summary_text", Text, nullable=False),
Column("batch_timestamp", DateTime(timezone=True),
server_default=func.now(), nullable=False),
)
Index("ix_article_summaries_batch_timestamp", article_summaries.c.batch_timestamp)