I think this one was for the quote description field - but we got it wrong so we need to seatch and find the correct field......
This commit is contained in:
+78
-14
@@ -68,6 +68,7 @@ def html_page(title: str, body: str) -> HTMLResponse:
|
||||
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
|
||||
pre { white-space: pre-wrap; word-break: break-word; background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; overflow-x: auto; }
|
||||
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e0f2fe; color: #075985; font-size: 0.85rem; margin: 2px 4px 2px 0; }
|
||||
.job-id { font-weight: 700; color: #111827; }
|
||||
.section { margin: 24px 0; }
|
||||
.toolbar { background: white; border: 1px solid #e5e7eb; border-radius: 10px; padding: 12px; margin-bottom: 16px; }
|
||||
input[type='text'] { padding: 8px; width: 280px; max-width: 100%; }
|
||||
@@ -139,6 +140,63 @@ def link_with_params(path, **params):
|
||||
return f"{path}?{urlencode(filtered)}" if filtered else path
|
||||
|
||||
|
||||
def resolve_generated_job_id(job_uuid: str) -> str:
|
||||
job_uuid = str(job_uuid or "").strip()
|
||||
if not job_uuid:
|
||||
return ""
|
||||
|
||||
try:
|
||||
with closing(get_poll_conn()) as conn:
|
||||
row = conn.execute(
|
||||
"select generated_job_id from job_metadata where job_uuid = ?",
|
||||
(job_uuid,),
|
||||
).fetchone()
|
||||
if row and row["generated_job_id"]:
|
||||
return str(row["generated_job_id"])
|
||||
except sqlite3.Error:
|
||||
pass
|
||||
|
||||
try:
|
||||
with closing(get_conn()) as conn:
|
||||
row = conn.execute(
|
||||
"""
|
||||
with jobs as (
|
||||
select
|
||||
json_extract(payload_json, '$.data.uuid') as job_uuid,
|
||||
json_extract(payload_json, '$.data.generated_job_id') as generated_job_id,
|
||||
received_at
|
||||
from webhook_events
|
||||
where json_extract(payload_json, '$.data.generated_job_id') is not null
|
||||
union all
|
||||
select
|
||||
json_extract(payload_json, '$.related.job.uuid') as job_uuid,
|
||||
json_extract(payload_json, '$.related.job.generated_job_id') as generated_job_id,
|
||||
received_at
|
||||
from webhook_form_responses
|
||||
where json_extract(payload_json, '$.related.job.generated_job_id') is not null
|
||||
)
|
||||
select generated_job_id
|
||||
from jobs
|
||||
where job_uuid = ?
|
||||
and generated_job_id is not null
|
||||
order by received_at desc
|
||||
limit 1
|
||||
""",
|
||||
(job_uuid,),
|
||||
).fetchone()
|
||||
if row and row["generated_job_id"]:
|
||||
return str(row["generated_job_id"])
|
||||
except sqlite3.Error:
|
||||
pass
|
||||
|
||||
return ""
|
||||
|
||||
|
||||
def job_id_html(job_uuid: str) -> str:
|
||||
generated_job_id = resolve_generated_job_id(job_uuid)
|
||||
return f"<span class='job-id'>{escape(generated_job_id)}</span>" if generated_job_id else ""
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
return {"ok": True, "db_path": DB_PATH, "state_db_path": STATE_DB_PATH, "poll_db_path": POLL_DB_PATH}
|
||||
@@ -459,6 +517,7 @@ def list_generated_materials(page: int = Query(1, ge=1)):
|
||||
table_rows.append(
|
||||
f"<tr>"
|
||||
f"<td><a href='/generated-materials/{row['id']}'>{row['id']}</a></td>"
|
||||
f"<td>{job_id_html(row['job_uuid'])}</td>"
|
||||
f"<td>{escape(row['job_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['form_response_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['job_material_uuid'] or '')}</td>"
|
||||
@@ -470,8 +529,8 @@ def list_generated_materials(page: int = Query(1, ge=1)):
|
||||
|
||||
body = f"""
|
||||
<table>
|
||||
<thead><tr><th>ID</th><th>Job UUID</th><th>Form response UUID</th><th>Job material UUID</th><th>Kind</th><th>Source question</th><th>Updated</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='7'>No rows found.</td></tr>"}</tbody>
|
||||
<thead><tr><th>ID</th><th>Job ID</th><th>Job UUID</th><th>Form response UUID</th><th>Job material UUID</th><th>Kind</th><th>Source question</th><th>Updated</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='8'>No rows found.</td></tr>"}</tbody>
|
||||
</table>
|
||||
<div class='pagination'>
|
||||
{f"<a href='{link_with_params('/generated-materials', page=page-1)}'>← Prev</a>" if page > 1 else ''}
|
||||
@@ -495,6 +554,7 @@ def generated_material_detail(row_id: int):
|
||||
body = f"""
|
||||
<div class='card summary-grid'>
|
||||
<div><strong>ID</strong></div><div>{row['id']}</div>
|
||||
<div><strong>Job ID</strong></div><div>{job_id_html(row['job_uuid'])}</div>
|
||||
<div><strong>Job UUID</strong></div><div>{escape(row['job_uuid'] or '')}</div>
|
||||
<div><strong>Form response UUID</strong></div><div>{escape(row['form_response_uuid'] or '')}</div>
|
||||
<div><strong>Job material UUID</strong></div><div>{escape(row['job_material_uuid'] or '')}</div>
|
||||
@@ -585,15 +645,15 @@ def list_remote_existing_incidents(page: int = Query(1, ge=1)):
|
||||
f"<tr><td><a href='/poll/remote-existing-incidents/{row['id']}'>{row['id']}</a></td>"
|
||||
f"<td>{escape(row['detected_at'] or '')}</td><td>{escape(row['action'] or '')}</td>"
|
||||
f"<td><a href='/poll/quote-template/{escape(row['form_response_uuid'])}'>{escape(row['form_response_uuid'])}</a></td>"
|
||||
f"<td>{escape(row['job_uuid'] or '')}</td><td>{run_link}</td>"
|
||||
f"<td>{job_id_html(row['job_uuid'])}</td><td>{escape(row['job_uuid'] or '')}</td><td>{run_link}</td>"
|
||||
f"<td>{row['desired_count']}</td><td>{row['remote_count']}</td><td>{row['remote_active_count']}</td>"
|
||||
f"<td>{escape((row['reason'] or '')[:180])}</td></tr>"
|
||||
)
|
||||
|
||||
body = f"""
|
||||
<table>
|
||||
<thead><tr><th>ID</th><th>Detected</th><th>Action</th><th>Form response UUID</th><th>Job UUID</th><th>Apply run</th><th>Desired</th><th>Remote rows</th><th>Active</th><th>Reason</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='10'>No remote-existing incidents found.</td></tr>"}</tbody>
|
||||
<thead><tr><th>ID</th><th>Detected</th><th>Action</th><th>Form response UUID</th><th>Job ID</th><th>Job UUID</th><th>Apply run</th><th>Desired</th><th>Remote rows</th><th>Active</th><th>Reason</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='11'>No remote-existing incidents found.</td></tr>"}</tbody>
|
||||
</table>
|
||||
<div class='pagination'>
|
||||
{f"<a href='{link_with_params('/poll/remote-existing-incidents', page=page-1)}'>← Prev</a>" if page > 1 else ''}
|
||||
@@ -631,6 +691,7 @@ def remote_existing_incident_detail(incident_id: int):
|
||||
<div><strong>Detected</strong></div><div>{escape(row['detected_at'] or '')}</div>
|
||||
<div><strong>Action</strong></div><div>{escape(row['action'] or '')}</div>
|
||||
<div><strong>Form response UUID</strong></div><div><a href='/poll/quote-template/{escape(row['form_response_uuid'])}'>{escape(row['form_response_uuid'])}</a></div>
|
||||
<div><strong>Job ID</strong></div><div>{job_id_html(row['job_uuid'])}</div>
|
||||
<div><strong>Job UUID</strong></div><div>{escape(row['job_uuid'] or '')}</div>
|
||||
<div><strong>Apply run</strong></div><div>{run_link}</div>
|
||||
<div><strong>Desired rows</strong></div><div>{row['desired_count']}</div>
|
||||
@@ -668,14 +729,14 @@ def list_apply_runs(page: int = Query(1, ge=1)):
|
||||
f"<tr><td><a href='/poll/apply-runs/{row['id']}'>{row['id']}</a></td>"
|
||||
f"<td>{escape(row['mode'] or '')}</td><td>{escape(row['status'] or '')}</td>"
|
||||
f"<td><a href='/poll/quote-template/{escape(row['form_response_uuid'])}'>{escape(row['form_response_uuid'])}</a></td>"
|
||||
f"<td>{escape(row['job_uuid'] or '')}</td><td>{escape(row['started_at'] or '')}</td><td>{escape(row['finished_at'] or '')}</td>"
|
||||
f"<td>{job_id_html(row['job_uuid'])}</td><td>{escape(row['job_uuid'] or '')}</td><td>{escape(row['started_at'] or '')}</td><td>{escape(row['finished_at'] or '')}</td>"
|
||||
f"<td>{row['desired_count']}</td><td>{row['created_count']}</td><td>{escape((row['error'] or '')[:160])}</td></tr>"
|
||||
)
|
||||
|
||||
body = f"""
|
||||
<table>
|
||||
<thead><tr><th>ID</th><th>Mode</th><th>Status</th><th>Form response UUID</th><th>Job UUID</th><th>Started</th><th>Finished</th><th>Desired</th><th>Created</th><th>Error</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='10'>No apply runs found yet.</td></tr>"}</tbody>
|
||||
<thead><tr><th>ID</th><th>Mode</th><th>Status</th><th>Form response UUID</th><th>Job ID</th><th>Job UUID</th><th>Started</th><th>Finished</th><th>Desired</th><th>Created</th><th>Error</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='11'>No apply runs found yet.</td></tr>"}</tbody>
|
||||
</table>
|
||||
<div class='pagination'>
|
||||
{f"<a href='{link_with_params('/poll/apply-runs', page=page-1)}'>← Prev</a>" if page > 1 else ''}
|
||||
@@ -727,6 +788,7 @@ def apply_run_detail(run_id: int):
|
||||
<div><strong>Mode</strong></div><div>{escape(run['mode'] or '')}</div>
|
||||
<div><strong>Status</strong></div><div>{escape(run['status'] or '')}</div>
|
||||
<div><strong>Form response UUID</strong></div><div><a href='/poll/quote-template/{escape(run['form_response_uuid'])}'>{escape(run['form_response_uuid'])}</a></div>
|
||||
<div><strong>Job ID</strong></div><div>{job_id_html(run['job_uuid'])}</div>
|
||||
<div><strong>Job UUID</strong></div><div>{escape(run['job_uuid'] or '')}</div>
|
||||
<div><strong>Started</strong></div><div>{escape(run['started_at'] or '')}</div>
|
||||
<div><strong>Finished</strong></div><div>{escape(run['finished_at'] or '')}</div>
|
||||
@@ -816,7 +878,7 @@ def list_polled_form_responses(q: str = Query(""), quote_only: int = Query(0), p
|
||||
f"<tr><td><a href='/poll/form-responses/{escape(row['uuid'])}'>{escape(row['uuid'])}</a></td>"
|
||||
f"<td>{escape(row['timestamp'] or '')}</td><td>{escape(row['edit_date'] or '')}</td>"
|
||||
f"<td>{escape(row['form_uuid'] or '')}<br>{quote_pill}</td>"
|
||||
f"<td>{escape(row['regarding_object'] or '')}</td><td>{escape(row['regarding_object_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['regarding_object'] or '')}</td><td>{job_id_html(row['regarding_object_uuid'])}</td><td>{escape(row['regarding_object_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['parse_status'] or '')}</td><td>{row['seen_count']}</td><td>{escape(row['last_seen_at'] or '')}</td></tr>"
|
||||
)
|
||||
|
||||
@@ -830,8 +892,8 @@ def list_polled_form_responses(q: str = Query(""), quote_only: int = Query(0), p
|
||||
</form>
|
||||
</div>
|
||||
<table>
|
||||
<thead><tr><th>UUID</th><th>Timestamp</th><th>Edit date</th><th>Form UUID</th><th>Regarding</th><th>Object UUID</th><th>Parse</th><th>Seen</th><th>Last seen</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='9'>No rows found.</td></tr>"}</tbody>
|
||||
<thead><tr><th>UUID</th><th>Timestamp</th><th>Edit date</th><th>Form UUID</th><th>Regarding</th><th>Job ID</th><th>Object UUID</th><th>Parse</th><th>Seen</th><th>Last seen</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='10'>No rows found.</td></tr>"}</tbody>
|
||||
</table>
|
||||
<div class='pagination'>
|
||||
{f"<a href='{link_with_params('/poll/form-responses', q=q, quote_only=quote_only, page=page-1)}'>← Prev</a>" if page > 1 else ''}
|
||||
@@ -871,6 +933,7 @@ def polled_form_response_detail(form_response_uuid: str):
|
||||
<div><strong>Edit date</strong></div><div>{escape(row['edit_date'] or '')}</div>
|
||||
<div><strong>Form UUID</strong></div><div>{escape(row['form_uuid'] or '')}</div>
|
||||
<div><strong>Regarding object</strong></div><div>{escape(row['regarding_object'] or '')}</div>
|
||||
<div><strong>Job ID</strong></div><div>{job_id_html(row['regarding_object_uuid'])}</div>
|
||||
<div><strong>Regarding UUID</strong></div><div>{escape(row['regarding_object_uuid'] or '')}</div>
|
||||
<div><strong>First seen</strong></div><div>{escape(row['first_seen_at'] or '')}</div>
|
||||
<div><strong>Last seen</strong></div><div>{escape(row['last_seen_at'] or '')}</div>
|
||||
@@ -911,15 +974,15 @@ def list_polled_quote_templates(page: int = Query(1, ge=1)):
|
||||
material_count = "?"
|
||||
table_rows.append(
|
||||
f"<tr><td><a href='/poll/quote-template/{escape(row['form_response_uuid'])}'>{escape(row['form_response_uuid'])}</a></td>"
|
||||
f"<td>{escape(row['discovered_at'] or '')}</td><td>{escape(row['job_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['discovered_at'] or '')}</td><td>{job_id_html(row['job_uuid'])}</td><td>{escape(row['job_uuid'] or '')}</td>"
|
||||
f"<td>{escape(row['description'] or '')}</td><td>{material_count}</td>"
|
||||
f"<td>{escape(row['queued_at'] or '')}</td><td>{escape(row['process_status'] or '')}</td></tr>"
|
||||
)
|
||||
|
||||
body = f"""
|
||||
<table>
|
||||
<thead><tr><th>Form response UUID</th><th>Discovered</th><th>Job UUID</th><th>Description</th><th>Rows</th><th>Queued</th><th>Status</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='7'>No quote template rows found.</td></tr>"}</tbody>
|
||||
<thead><tr><th>Form response UUID</th><th>Discovered</th><th>Job ID</th><th>Job UUID</th><th>Description</th><th>Rows</th><th>Queued</th><th>Status</th></tr></thead>
|
||||
<tbody>{''.join(table_rows) or "<tr><td colspan='8'>No quote template rows found.</td></tr>"}</tbody>
|
||||
</table>
|
||||
<div class='pagination'>
|
||||
{f"<a href='{link_with_params('/poll/quote-template', page=page-1)}'>← Prev</a>" if page > 1 else ''}
|
||||
@@ -979,6 +1042,7 @@ def polled_quote_template_detail(form_response_uuid: str):
|
||||
<div class='card summary-grid'>
|
||||
<div><strong>Form response UUID</strong></div><div>{escape(row['form_response_uuid'])}</div>
|
||||
<div><strong>Discovered</strong></div><div>{escape(row['discovered_at'] or '')}</div>
|
||||
<div><strong>Job ID</strong></div><div>{job_id_html(row['job_uuid'])}</div>
|
||||
<div><strong>Job UUID</strong></div><div>{escape(row['job_uuid'] or '')}</div>
|
||||
<div><strong>Form UUID</strong></div><div>{escape(row['form_uuid'] or '')}</div>
|
||||
<div><strong>Author</strong></div><div>{escape(row['author_name'] or '')}</div>
|
||||
|
||||
Reference in New Issue
Block a user