Hooks the topology_worker's post-terminal path into a new notify_run_completed repo helper that atomically transitions the topic processing → reviewing when the completed run has research_topic_id set AND no siblings for that topic are still queued or running. Guarded on status='processing' so a retry, a re-fire, or a topic already past processing are all no-ops. Best-effort at the worker; DB hiccups are logged and never fail the run. The manual /submit-review endpoint stays as an escape hatch for topics that end up parked in processing with nothing to complete (updated the doc comment).
23 lines
935 B
JSON
23 lines
935 B
JSON
{
|
|
"db_name": "PostgreSQL",
|
|
"query": "UPDATE research_topics t\n SET status = 'reviewing', updated_at = now()\n WHERE t.id = (\n SELECT research_topic_id FROM topology_runs\n WHERE id = $1 AND research_topic_id IS NOT NULL\n )\n AND t.status = 'processing'\n AND NOT EXISTS (\n SELECT 1 FROM topology_runs\n WHERE research_topic_id = t.id\n AND id <> $1\n AND status IN ('queued', 'running')\n )\n RETURNING t.id",
|
|
"describe": {
|
|
"columns": [
|
|
{
|
|
"ordinal": 0,
|
|
"name": "id",
|
|
"type_info": "Uuid"
|
|
}
|
|
],
|
|
"parameters": {
|
|
"Left": [
|
|
"Uuid"
|
|
]
|
|
},
|
|
"nullable": [
|
|
false
|
|
]
|
|
},
|
|
"hash": "e26955627419e4773f72abb9010fcdcd589d777f0fd20b444a629feed2bf75e4"
|
|
}
|