{ "db_name": "PostgreSQL", "query": "SELECT a.id, a.name, a.accent,\n COALESCE(SUM(u.credits), 0)::BIGINT AS \"credits!\",\n COALESCE(SUM(u.tokens_in + u.tokens_out), 0)::BIGINT AS \"tokens!\",\n COUNT(u.id)::BIGINT AS \"runs!\"\n FROM agents a\n LEFT JOIN usage_events u ON u.agent_id = a.id\n -- deleted_at: a soft-deleted agent is gone everywhere else, so\n -- listing it here made deletion look like a no-op — the operator\n -- deletes it, the board still shows it, and deleting again does\n -- nothing because the row is already marked.\n WHERE a.workspace_id = $1 AND a.deleted_at IS NULL\n GROUP BY a.id, a.name, a.accent\n ORDER BY \"credits!\" DESC, \"tokens!\" DESC, a.name", "describe": { "columns": [ { "ordinal": 0, "name": "id", "type_info": "Uuid" }, { "ordinal": 1, "name": "name", "type_info": "Text" }, { "ordinal": 2, "name": "accent", "type_info": "Text" }, { "ordinal": 3, "name": "credits!", "type_info": "Int8" }, { "ordinal": 4, "name": "tokens!", "type_info": "Int8" }, { "ordinal": 5, "name": "runs!", "type_info": "Int8" } ], "parameters": { "Left": [ "Uuid" ] }, "nullable": [ false, false, false, null, null, null ] }, "hash": "d5bc028ca030daed4e6111990945d8d7011414d830f7d6d0a04980efb79af2a6" }