{ "db_name": "SQLite", "query": "\n SELECT\n w.id as \"id!: Uuid\",\n w.task_id as \"task_id!: Uuid\",\n w.container_ref,\n w.branch as \"branch!\",\n w.setup_completed_at as \"setup_completed_at: DateTime\",\n w.created_at as \"created_at!: DateTime\",\n w.updated_at as \"updated_at!: DateTime\"\n FROM workspaces w\n LEFT JOIN sessions s ON w.id = s.workspace_id\n LEFT JOIN execution_processes ep ON s.id = ep.session_id AND ep.completed_at IS NOT NULL\n WHERE w.container_ref IS NOT NULL\n AND w.id NOT IN (\n SELECT DISTINCT s2.workspace_id\n FROM sessions s2\n JOIN execution_processes ep2 ON s2.id = ep2.session_id\n WHERE ep2.completed_at IS NULL\n )\n GROUP BY w.id, w.container_ref, w.updated_at\n HAVING datetime('now', '-72 hours') > datetime(\n MAX(\n CASE\n WHEN ep.completed_at IS NOT NULL THEN ep.completed_at\n ELSE w.updated_at\n END\n )\n )\n ORDER BY MAX(\n CASE\n WHEN ep.completed_at IS NOT NULL THEN ep.completed_at\n ELSE w.updated_at\n END\n ) ASC\n ", "describe": { "columns": [ { "name": "id!: Uuid", "ordinal": 0, "type_info": "Blob" }, { "name": "task_id!: Uuid", "ordinal": 1, "type_info": "Blob" }, { "name": "container_ref", "ordinal": 2, "type_info": "Text" }, { "name": "branch!", "ordinal": 3, "type_info": "Text" }, { "name": "setup_completed_at: DateTime", "ordinal": 4, "type_info": "Datetime" }, { "name": "created_at!: DateTime", "ordinal": 5, "type_info": "Text" }, { "name": "updated_at!: DateTime", "ordinal": 6, "type_info": "Text" } ], "parameters": { "Right": 0 }, "nullable": [ true, true, true, true, true, true, true ] }, "hash": "3960255f06f9753bc116d1aa1d65e0c5bf402d52130057fbaa2c9da7f0173e64" }