fix: fix indentation and add try/finally in digest startup

This commit is contained in:
pyr0ball 2026-03-20 02:36:23 -07:00
parent b56ad40c9e
commit 7d9be91aab
2 changed files with 16 additions and 14 deletions

View file

@ -57,16 +57,18 @@ def _strip_html(text: str | None) -> str | None:
def _startup(): def _startup():
"""Ensure digest_queue table exists (dev-api may run against an existing DB).""" """Ensure digest_queue table exists (dev-api may run against an existing DB)."""
db = _get_db() db = _get_db()
db.execute(""" try:
CREATE TABLE IF NOT EXISTS digest_queue ( db.execute("""
id INTEGER PRIMARY KEY, CREATE TABLE IF NOT EXISTS digest_queue (
job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id), id INTEGER PRIMARY KEY,
created_at TEXT DEFAULT (datetime('now')), job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id),
UNIQUE(job_contact_id) created_at TEXT DEFAULT (datetime('now')),
) UNIQUE(job_contact_id)
""") )
db.commit() """)
db.close() db.commit()
finally:
db.close()
def _row_to_job(row) -> dict: def _row_to_job(row) -> dict:

View file

@ -139,10 +139,10 @@ CREATE TABLE IF NOT EXISTS survey_responses (
CREATE_DIGEST_QUEUE = """ CREATE_DIGEST_QUEUE = """
CREATE TABLE IF NOT EXISTS digest_queue ( CREATE TABLE IF NOT EXISTS digest_queue (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id), job_contact_id INTEGER NOT NULL REFERENCES job_contacts(id),
created_at TEXT DEFAULT (datetime('now')), created_at TEXT DEFAULT (datetime('now')),
UNIQUE(job_contact_id) UNIQUE(job_contact_id)
) )
""" """