diff --git a/goodnews/api.py b/goodnews/api.py index 35a1145..81c149f 100644 --- a/goodnews/api.py +++ b/goodnews/api.py @@ -28,7 +28,7 @@ from fastapi.staticfiles import StaticFiles from pydantic import BaseModel from . import feeds, queries -from .db import connect, init_db +from .db import connect from .filters import filter_articles, prefs_from_json from .hero import safe_to_lead from .llm import LocalModelClient @@ -218,9 +218,13 @@ def create_app() -> FastAPI: @app.get("/healthz") def healthz() -> dict: - with get_conn() as conn: - init_db(conn) - scored = conn.execute("SELECT COUNT(*) FROM article_scores").fetchone()[0] + # Read-only: the schema is owned by the ingestion CLI, so the API never + # writes (it can run as a read-only replica against a shared DB). + try: + with get_conn() as conn: + scored = conn.execute("SELECT COUNT(*) FROM article_scores").fetchone()[0] + except sqlite3.Error: + scored = 0 return {"status": "ok", "scored_articles": scored} @app.get("/api/categories", response_model=CategoriesResponse)