| import psycopg | |
| from app.core.config import DATABASE_URL | |
| conn = psycopg.connect(DATABASE_URL) | |
| try: | |
| cur = conn.cursor() | |
| cur.execute(""" | |
| SELECT | |
| wr.id, | |
| wr.status, | |
| wr.document_version_id | |
| FROM workflow_runs wr | |
| WHERE wr.id IN ( | |
| SELECT DISTINCT thread_id::uuid | |
| FROM checkpoints | |
| ) | |
| ORDER BY wr.status, wr.id | |
| """) | |
| rows = cur.fetchall() | |
| print("=" * 70) | |
| print("CHECKPOINT-BACKED WORKFLOWS") | |
| print("=" * 70) | |
| for workflow_id, status, version_id in rows: | |
| print() | |
| print("WORKFLOW:", workflow_id) | |
| print("STATUS:", status) | |
| print("DOCUMENT VERSION:", version_id) | |
| finally: | |
| conn.close() | |