fix: fix indentation and add try/finally in digest startup
This commit is contained in:
parent
6a1ee3ed28
commit
0590a3a12e
2 changed files with 16 additions and 14 deletions
22
dev-api.py
22
dev-api.py
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue