Add book title to autocomplete suggestions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Aaron Roberts
2026-06-09 18:29:14 +01:00
parent 5ea18d76d6
commit dc5a1a4ff5
5 changed files with 21 additions and 6 deletions

View File

@@ -756,13 +756,14 @@ async def list_jobs(
@app.get("/api/jobs/suggestions")
async def job_suggestions():
"""Return distinct values for author, chapter, and reviewer_name to power autocomplete."""
"""Return distinct values for author, book, chapter, and reviewer_name to power autocomplete."""
try:
with get_db() as conn:
with conn.cursor() as cur:
cur.execute("""
SELECT
array_remove(array_agg(DISTINCT author ORDER BY author), NULL) AS authors,
array_remove(array_agg(DISTINCT book ORDER BY book), NULL) AS books,
array_remove(array_agg(DISTINCT chapter ORDER BY chapter), NULL) AS chapters,
array_remove(array_agg(DISTINCT reviewer_name ORDER BY reviewer_name), NULL) AS reviewers
FROM ocr_jobs
@@ -774,6 +775,7 @@ async def job_suggestions():
return JSONResponse({
"authors": row["authors"] or [],
"books": row["books"] or [],
"chapters": row["chapters"] or [],
"reviewers": row["reviewers"] or [],
})